Atoms in solid are very close(compact) to each other. Hence they have definite volume.
Atoms in liquid are a bit apart from each other. Hence they can take irregular shapes but their volume is constant.
Atoms in gas are far apart from each other which helps them to move freely between collisions. Gases expand quickly when released in surrounding and takes the shape of the container. It has infinite volume.