How do states of matter change?
By application of energy
When a solid is heated it changes to a liquid. Further heating converts a liquid to a gas. The inverse process produces results in reverse order i.e. gas->liquid->solid.
Entropy. Each state of matter has a different level of organization or disorder. Moving from one state to another requires or releases energy.
Oddly freezing is an exothermic reaction. When liquid water becomes a solid it becomes more organized and structured This is a decrease in entropy or disorder. As the natural tendency of all the universe is to go from order to disorder. Energy is released and the water becomes colder as it loses energy.
Melting ice is an endothermic reaction. When solid water ( ice) is heated energy is added to the system. The energy is absorbed breaking the hydrogen bonds that hold the water molecules together as a solid. The temperature of the water does not increase until all of the solid is melted into a liquid. This is an increase in entropy as the water is less organized and structured than the ice.
The transitions from liquid to gas and gas to liquid are much the same. Water is more structured than gas ( steam) . So when a gas condenses into a liquid heat is released. (exothermic) This is why steam can burn if it touches skin. Turning water into steam requires energy ( endothermic)