A star forms from a vast cloud of hydrogen, a bit of helium, and a dash of other chemical elements. A star is basically made of hydrogen just like the Goodyear blimp (only a star has much higher gas density and pressure)!
There are 300 million stars in the Milky Way, and many more clouds waiting around to perhaps form new stars in the future. So what is it that happens to a cloud that makes it form into a star? A star like our Sun started out as a gigantic cloud about 40,000 astronomical units in size, where an astronomical unit is the distance from the Sun to the Earth.
Such clouds are often keeping their own shape pretty well because the gravity pushing a cloud in the inward direction is just balanced by the pressure of the gas pushing outward. This keeps clouds stable against collapse into stars, so how do stars form at all? This is still a bit of an unsolved problem.
We do know that if for some reason such a gigantic cloud were to be compressed every so slightly that there would be increased gravity pushing down on the cloud. In return there would be an increased push back from the hydrogen gas. This would happen at the surface and at all layers underneath the surface too in what is called a shock wave.
It is likely that the gas will remain stable to a small shock. If, however, the push is more rapid, such that the shock propagates faster than a hydrogen molecule can 'fall' to the center on its own, there will be a different fate.
In this case the cloud will not be able to cope with the shock and will continue its contraction. Under the right conditions, a star will be born. Some galaxies manage their star forming clouds very well, and stars form at a healthy rate of about 1 star per year (like the Milky Way). Other galaxies form stars extremely rapidly in what are termed 'starbursts,' using up all their star forming clouds in one go, like a great fireworks exhibition.
Understanding the physical conditions governing the collapse of clouds into stars in different galaxy environements is one of the outstanding problems in extragalactic astronomy.