During a phase change, like the conversion from liquid to solid (freezing), the temperature of the substance remains constant. However, energy is either absorbed or released during this process. In the case of freezing, the liquid water molecules lose energy to form a more ordered solid structure (ice).
This energy loss manifests as a decrease in the internal energy of the water. Internal energy is the sum of all kinetic and potential energies of the molecules within the substance. When water freezes, the molecules slow down (kinetic energy decreases) and form bonds with each other (potential energy decreases). The release of this energy is known as the latent heat of fusion. Because the water releases energy in the form of heat during the freezing process, its internal energy decreases.