There are many different types of fog, but fog is mostly formed when southerly winds bring warm, moist air into a region, pushing out a cooler air mass.
As the warm, moist air flows over a colder surface, dense fog often forms.
Warm, moist air is cooled from below as it flows over the colder surface. If the air is near saturation, the moisture will condense out of the cooled air and form fog.
With light winds, the fog near the ground can become very dense causing reduced visibilities and making it hard to see.