The temperature of a body increases or decreases when heat is supplied or taken away from the body.
When a substance changes its state from solid to liquid, or liquid to gaseous state, the substance absorbs the heat given to it. This heat energy is used move the molecules in the substance a little more distant than in the previous state. There is kinetic energy (velocity/speed) of the molecules in any substance. The kinetic energy increases when the substance is given heat.
When the substance changes its state, the heat supplied is used to increase the distance between the molecules/particles of the substance. The temperature remains constant during this conversion. The amount of heat required to change the state is called "latent heat" or fusion or vapourization.
When the substance freezes, or solidifies or liquefies from gas, the heat is absorbed from the substance. The molecules of the substance come closer to each other. Then energy in the molecules remains the same. Only the distance between the particles of the substance changes. So temperature remains same. The energy released is called latent heat of fusion or condensation.