Inside a cassette tape, you'll find a length of magnetic tape that is wound around two spools. The tape is coated with a thin layer of magnetic material, often made of iron oxide. This coating is what allows the tape to store audio or other types of data.
When you insert a cassette tape into a player, the player's mechanism takes over. The tape passes between a set of plastic guides and over a magnetic playback head. The playback head contains a tiny electromagnet that is sensitive to magnetic fields.
As the tape moves, the playback head reads the magnetic signals on the tape. These signals represent the audio or data that was previously recorded onto the tape. The electromagnet in the playback head converts the magnetic signals into electrical signals, which are then amplified and sent to the speakers or other output devices.
To record on a cassette tape, the process is reversed. An input device, such as a microphone, converts sound or data into electrical signals. These signals are then sent to a recording head, which converts them into magnetic signals. The magnetic signals are then written onto the tape's magnetic coating.