In case of molarity the volume of solvent is taken but in case of molality the mass of solvent is taken. With change in temprature the volume can increase or decrease but the mass remains same . So molality is preferred over the molarity.
The main reason for this is that the molarity is the number of moles of solute present in 1 litre of the solvent.
Where as the molality is the number of moles of the solute present in 1 kilogram of the solvent.