When the temperature decreases, molecules of gas lose its kinetic energy and become slower, when the speed of molecules decreases, the force of attraction between the molecules increases and molecules come closer to each other and gets converted into liquid.
For example, if we take the example of air, air can be liquefied by cooling and applying pressure. When the temperature of the air decreases to a certain value, its molecule lose their kinetic energy and come closer to each other as the intermolecular force of attraction between the molecules increases and air gets converted into liquid.