AVR USART Random Behaviour
It is a good habit to flush serial input buffer on your PC before starting to use it to ensure sender and receiver are synchronized. One useful trick is not to send your raw data, but encapsulate it in a frame of which you can easily recognize start, end and payload. You probably want to add a checksum too, so you can simply check if the data you received is the same as the data you tried to send.

Useful similar other questions:


Why do I need to wait a few moments before sending serial data on my AVR?
RS232 hotplugging