When a substance changes their state of matter i.e. solid, liquid, gaseous state changes into different state is said to be phase transition. It occurs under specific temperature and pressure and also depends upon the environmental conditions.
For phase transition, a sufficient amount of energy is supplied for transformation of one state to another state and energy can also be withdrawn for the transformation of a state to different state as some molecules needs large amount energy and some needs small amount of energy. In this process, molecules are not present in static state, there is continuous movement of molecules takes place in this process.
Thus, when energy is withdrawn also supplied then this process occurs in the molecules.