Basically the existence of different states of matter has to do with Inter-molecular forces, Temperature of its surroundings and itself and the Density of the substance.
This image below shows you how the transition between each states occur (called Phase transitions).
These transitions occur based on the change in temperature of the substance
Now if you compress (increase pressure) and reduce the temperature of gasses like $CO_2$ then it can exist in solid state which is generally called Dry Ice (5.18 bar, - 56.6°C)
But there are other exotic states of matter out there, like Plasma and Bose–Einstein condensate