You know how when you get into the car with wet hair, after a short while your driver-side window will be fogged up, and the fog will be creeping across the windscreen and into the back window? The effect is quite dramatic if you have a lot of hair and if it is chilly out. It’s because the water in your hair is being heated by your head, and the humidity created in this small microcosm is a mix of air and evaporated water (as you might well suspect) which rushes for the windows, because the glass is cooler than the climate you’ve created – and we all remember that heat goes from source to sink. The sink is the colder window. It’s exactly what happens when you have a frosty beer on a hot day and the outside becomes covered in condensation. The hot air wants to go to a lower-pressure area, and that’s the cold, so off it goes to cling to the beer, exactly the way you want to.
So the warm, wet air heads for the windows, and when it hits the window, the water vapor condenses back into water. This is the same effect as when it rains outside and the windows fog up. The glass cools from the rain, but the temperature in the car stays the same, so they begin to fog up as the available moisture in the air is carried (by the air that is wooshing to the windows) to the glass. That is also why turning on the air conditioning will alleviate the issue; it cools down the internal air and cools down the glass.
If you fog up the windows doing what Rose and Jack in Titanic did, then rest easy knowing that the condensate is sweat and damp, fetid air from your lustful lungs (basically the same stuff that clings to the window when it rains).