Fog is a cloud at ground level: fine droplets of fresh water. On its own it does the paint no harm. What it carries is the part worth thinking about.
Air coming off the Pacific holds microscopic salt particles. They settle on the car with the moisture, and when the fog burns off the water evaporates and the salt stays behind as a thin, usually invisible film. The next foggy night wets it again. That wet-dry cycle, repeated for weeks, is the real exposure.
Salt matters because it holds water. Metal that would dry out in an hour stays damp for much longer with salt sitting on it, and damp, salty metal is how corrosion gets started.
None of this is unique to San Francisco, and it is far milder than a snowy-state winter, where road salt is thrown directly onto the car. Here it is a light, constant dusting rather than a dose. That is why the damage is slow, and why it is so easy to prevent.