The force that is responsible for attracting the particles to each other is known as the intermolecular force of attraction. And its strength varies depending upon the state of the substance.
There are kinds of molecular forces known as Hydrogen bonding, Dispersion, Ion dipole, and Dipole-Dipole.
Solids have the greatest amount of this force, which is why they are strong and do not change their structure.
It is much less in gases since gases are not rigid and can take the shape of a vessel and be squeezed.
Liquids have a force of attraction that is weaker than solids but stronger than gases. Liquids are not solids and are not as compressible as gases.