A change of state requires energy
When a substance is melting or boiling, you’re still putting in energy and so increasing the internal energy, but the energy’s used for breaking intermolecular bonds rather than raising the temperature. There are flats spots on the heating graph where energy is being transferred but not being used to change the temperature.
When a substance is condensing or freezing, bonds are forming between particles which releases energy. This means the internal energy decreases, but the temperature doesn’t go down until all the substances has turned to liquid or a solid. The flat parts of the graph show this energy transfer.
The energy needed to change the state of a substance is called latent heat
Specific latent heat is the energy needed to change the state of a 1kg matter
There’s a formula for specific latent heat
You can work out the energy needed when a substance of mass m changes state using this formula
Energy = Mass x Specific latent heat
Energy is given in joules, mass in kg and SLH in J/kg