As already commented, there are only three relays a normal circuit goes through. The exit relay obviously knows it is the exit - because it is asked to make a connection to the outside world. For middle and entry nodes, it is not as clear-cut, but still pretty easy to figure out in most cases: If the connection comes from a known Tor relay IP address, most likely the relay is being used as a middle node, otherwise as an entry node.
But I think one thing you're not clear on, and that also hasn't been commented on before: The "layers" of encryption do not actually make the data that gets sent through the network any longer, instead the data just gets changed. Imagine you had a simple scheme where each relay just changed each text character to be the next one in the alphabet. If the original text is then "hello my friend", the first encryption step would be "idmmp nz gsjdoe" - one "layer" was added, but the length didn't change.