Normally the heat supplied increases the kinetic energy of the molecules of the substance due to which temperature of the substance rises.
During melting or cooling, there is a large change in volume at large distances from each other against attraction between them. Then only potential energy increases.