The atoms in a sample are close together but can side past one another. As the atoms lose energy, they move slower. The atoms become locked in place because of attractive forces between them.
Which change of state is taking place
Gas to solid
Gas to liquid
Liquid to solid
Solid to liquid