Fogging is caused by a sudden temperature difference between the inner and outer surface of glass, resulting in condensation. Anti-fog prevents this sweating reaction before it starts by combatting heat and humidity.
eBay