Molecules of any kind of matter attract each other. The force of attraction between the molecules is called intermolecular force.
The intermolecular force between molecules depends on the space between them. This space between the molecules is called intermolecular space. The greater the space between molecules, the lesser the force of attraction. The intermolecular force is high when the space between the molecules is less.
The molecules in a solid are very closely arranged, resulting in very small intermolecular spaces in solids. The intermolecular force of attraction in solids is very strong because of the small intermolecular spaces. This is also the reason why solids cannot be compressed.
The molecules in a solid cannot interchange their positions, and hence, solids have a definite shape and definite volume. In contrast to solids, the molecular arrangement in liquids is not fixed.
The comparatively larger intermolecular spaces between the molecules result in weak intermolecular forces of attraction. The molecules in a liquid can interchange their positions because of the flexible arrangement and weak intermolecular force. This is why liquids flow and do not have any definite shape. Instead, they take the shape of the container. Though the intermolecular force between molecules in a liquid is less as compared to solids, the molecules cannot move far apart. Hence, liquids have a definite volume, though they do not have a definite shape.
The molecules in a gas are very far apart from each other. Therefore, the intermolecular space in gases is very large and the intermolecular force is negligible. Gases do not have any definite shape or definite volume because of the loose molecular arrangement. They can fill the entire space available to them.
Unlike solids and liquids, gases are easily compressible. This is because when force is applied to gases, the large intermolecular spaces decrease, thereby decreasing the volume.