Its mainly due to a sudden drop/increase in temperature. Coming home with a hot engine on a cold night can cause condensation to collect in the headlights
They aren't sealed up, so can breathe, but occasionally too much moisture collects in them and it can't evaporate on its own