There are three states of matter: solids, liquids and gases. In many cases, the same element can exist in all three states.
When matter changes from one state to another it is called a phase transition. Examples include:
There are many examples of matter going through each of these transitions.
Under certain circumstances, gas can transform directly into a solid. This process is called deposition.
Now you have some examples of gas to solid and can better understand how transitions occur between different states of matter.