During the change of state,heat energy is used to change the bonding between the molecules. In case of melting added energy is used to break the bonds between molecules. In case of freezing energy is subtracted as the molecules bond to one another. These energy changes are not the changes in kinetic energy.So temperature remains constant during the change of state.