This happens on a bit level of the receiver electronics.
For every byte you have to receive 8 bits. At this point in communication you only decoded the signal (eg. converted the electrical power or voltage) levels to bits. You receive bits in the buffer.
You are constantly filling the buffer (on a bit level), so you can check the buffer to see if you received anything. First you receive a lot of 000000, but then at one point message arrives, and bits in the buffer start to have different values.
Now if you are lucky first bit of the message arrives on let's say 8th or 16th place in the buffer (or 0th). This are all the bits that also start a logical representation of a byte.
If you are not that lucky, you just pushed in a 0 on 8th place of a buffer, and you would start filling the message in on the 9th place, which would in mean first seven bits from the original first byte would be received as first byte. And a second byte would be received as a last bit of the original first byte and first 7 bits of the original second byte and so on. This would mess things up good.
You have to be able to slide in some zeros in to the buffer in order to check up with the start filling the message in on the "start of byte position" of the buffer. But since you know how many zeros you had to fill in, you know how much delay this added for certain message (if you know the frequency of transmission).
Just to make things more exact:
you push the preamble in the buffer at random bytes, this is how you know you are getting something. sync is then used to sync the trasmission (eg. fill in the zerros so you start on right bit position).