Here's how the Sun formed:
1. Gravitational Collapse: A vast cloud of gas and dust in space, called a nebula, began to collapse under its own gravity.
2. Heat and Pressure Build: As the cloud collapsed, the material inside got denser and hotter due to increasing pressure.
3. Nuclear Fusion: At the core of the collapsing cloud, the pressure and temperature reached a point where hydrogen atoms began to fuse together, forming helium and releasing immense amounts of energy. This process is called nuclear fusion.
4. Sun Ignition: The energy released from nuclear fusion created outward pressure that balanced the inward force of gravity, creating a stable star.
Therefore, the Sun wasn't created by gas "getting into space," but rather by the gravitational collapse of a giant cloud of gas and dust, leading to nuclear fusion at its core.