Exactly the title. There needs to be a pressure to prevent gases from perpetually expanding, right? Bear with me, I'm not a physicist or studying to be one.
This is probably not a valid stack-exchange question since the answer is available online just by doing a Google search, but the answer is gravity. That's why gas giants are largely gaseous, and the tiny Moon has virtually no atmosphere, and the Earth is somewhere in between.