The statement is partially correct but not complete. To form a nebula, gravity does indeed pull matter together; however, it's more accurate to say that gravity causes a collapse of gas and dust, leading to the formation of a nebula. Pressure changes can occur in the process, but the primary driving force is gravity.
So, while your statement contains some correct elements, it would be better phrased as: "To form a nebula, gravity pulls matter together."