The signal coming out of your CD player headphone socket (or walkman, or MP3 player, or whatever) is an analogue electrical signal. This means that any loudspeaker (normally a pair of headphones, which are of course just tiny loudspeakers) can be plugged into it.
The cassette with the cable on it is an electric/magnetic converter - it changes the analogue electrical signal from the cd player into a magnetic one that the magnetic heads in the cassette player read.
The cassette has a little magnetic head in it instead of magnetised tape (in a normal cassette) - the little head in the cassette 'squirts' magnetic information directly into the read-head of the cassette player. This is then changed back into an electrical signal by the cassette player, amplified, and sent to the relevant loudspeakers in the normal way. In this case, your car hi-fi.
They don't work in all cassette players - some have automatic sensors that tell them how tight or loose the magnetic tape is (to ensure against wow & flutter, or tape damage), and normally these sensors get confused when there is simply no tape! It stops, or continuously auto-reverses. Either way, you don't get to hear the music. Most of them work fine.
QED. I think. Clear?
(wow & flutter is a nickname for when the tape is too loose or tight on the spools - as it turns while playing, it speeds and up and slows down, which can be very nauseating since it can be very marginal but subliminally or otherwise noticeable. To fix this you fast forward and rewind the tape completely several times on a good machine - this repacks the tape evenly onto the spools and corrects the problem (unless the player has low battery strength))