Although most substances can occur in any of the four stages of matter (solid, liquid, gas or plasma), the factors that determine the substance's state are its chemical structure and the temperature. When the temperature increases, it excites the individual molecules, causing them to move around faster and become further apart from one another.
The opposite is also true, as decreasing the temperature slows the molecules down and puts them into a closer, more orderly arrangement.
While adding or taking away energy by increasing or decreasing the temperature of the substance results in that substance changing its physical state, such as moving from liquid to gas or solid, the way the molecules are arranged plays a major role in what state that substance is at a certain temperature. This is why some things, such as water, can be liquid at room temperature, while others like helium or oxygen may exist as a gas at the same temperature.
When a substance changes from one state to another, the change is only a physical one, as the temperature change doesn't have an effect on its chemical structure. For instance, water is still H2O whether it is liquid water, ice or water vapor.