Clouds form when air that is warm and moist cools and expands. Clouds are just tiny droplets of water in the atmosphere. As you can see from the image below, the air cools as it rises, but cool air is able to hold less water than warm air. Thus, this excess water in the cool air condenses, and when enough of it does so, a cloud is formed. ![https://useruploads.socratic.org/vVgWLotETfO1GISQyp5N_how_clouds_form.jpg)
Clouds are formed by way of four processes : 1) surface heating, 2) mountains and terrains, 3) air masses that are forced to rise and cool, and 4) cold or warm weather fronts.
1) The first process is perhaps the simplest: the sun heats the earth and thus the air, this warm air rises, expands, and cools, forming clouds like in the image above.
2) Clouds are also formed when air encounters mountains or other topography. The air rises and cools and, again, the air cannot hold all of the water it held when warm so clouds form.
3) The air is also forced to rise when wind in a low pressure system forces the air to rise up. Related to number 2, if air is forced to rise because of topography that slopes upwards, clouds may also form.
4) Finally, weather fronts cause cloud formation. Specifically, warm fronts create clouds because the warm air rises above the cold air and cold fronts create clouds because the cold air displaces or moves the warm air up.
To conclude, many factors affect cloud formation, including topography, air temperature, and humidity.
Here's a very comprehensive link on cloud formation if you're looking for more.
Additionally, clouds can form in areas where precipitation has been ongoing or particularly heavy. The falling precipitation brings moisture lower down in the atmosphere, and we get a ragged layer (either stratus or stratus fractus) form, usually within 1,500 ft of the ground or lower.
Finally, since Fog is cloud at the surface of the Earth, in areas where fog has formed, surface winds can lift the fog, once it is aloft it becomes a cloud layer (stratus).