Later, Gravity pulled the Hydrogen
and Helium together to form stars,
and galaxies
Heavier elements (Carbon, Oxygen, etc) were formed inside stars
Stars burned out and exploded
and expelled the heavier elements
(carbon and oxygen and other
elements) that formed planets