The self-gravity of matter creates filamentary structures and the density at the intersections of the filaments increases. Around 200 million years after the Big Bang, active star formation ignites in the high density regions, which leads to the formation of galaxies. The gas in the galaxy is blown off by active stellar wind and supernovae, then the gas returns to the galaxy and causes another burst of star formation.
For details: See the press release "
ALMA Finds Oxygen 13.28 Billion Light-Years Away - Most Distant Oxygen Indicates Mature Nature of a Young Galaxy".
Credit: ALMA (ESO/NAOJ/NRAO)