That's like asking how a computer works - the answer is the same anyway. Data is stored in bits that are either on or off, and the programme that reads the info uses this to convert it back to a form we can understand.
I don't even know what an MP3 player is; and I have a number of audio items; including a keyboard, mixing recorder, DVD player,etc. However , I am an O.A.P. so perhaps should be forgiven for my ignorance of modern technology.