Yes its to do with speed of heat transfer and also the question of where will the heat go?
The second question is the significant one.
In both cases the air expands and cools as it expands because some of its internal heat energy goes to do the work of expansion against the external (air) pressure.
The expanding air becomes cooler than the surrounding air because heat does not have time to transfer. Eventually the temperatures will equalise.
In the case of the cloud formation the air cools sufficiently to drop below the local dew point and so some water vapour condenses out to form the cloud.