Condensation occurs when the amount of water vapor in the air is too high under given conditions or when the air temperature drops sharply.
This happens because as temperatures rise, the ability of the air to absorb water vapor increases.
When the air temperature drops to a value where the relative humidity is 100%, water vapor starts to precipitate as water (dew point).
In correctly designed and thermally insulated buildings this does not occur, even when the temperature in a part of the envelope drops below zero.
The direction of water vapor diffusion is influenced by the temperatures on both sides of the envelope, the degree of saturation, and pressure differences between the two sides of the envelope.
This means that it is not always just about the moisture coming out of the building, and the direction of diffusion changes throughout the year and sometimes even throughout the day.