Solids have strong forces of attraction between particles which hold them in fixed positions in a regular lattice arrangement. They vibrate in fixed positions as they have little energy.
Liquids have some forces of attraction between particles and a medium amount of energy so are still touching but they can move past each other.
Gasses have a relatively high amount of energy so move quickly in any direction. They are free to move in straight lines unless they collide.
During melting, the particles gain energy so overcome the attractions between themselves enough to move past each other out of their fixed positions.
During boiling, the particles gain energy so move faster and overcome the attractions between each other and move away so are no longer touching.
During freezing, the particles lose energy so no longer overcome the forces of attraction between themselves enough to move past each other so vibrate in fixed positions.
During condensation, the particles lose energy so move slower and can no longer overcome the attractions between themselves enough to be able to move away from each other so are now touching.