Galaxies are believed to form hierarchically within vast halos of dark matter, following the 'Lambda-CDM' cosmological model.
The prevailing cosmological model, Lambda-CDM (Lambda-Cold Dark Matter), posits that the universe is dominated by dark energy (Lambda) and cold dark matter. In this framework, galaxies do not form in isolation but rather grow from the bottom up. Small overdensities in the early universe, amplified by the gravitational pull of dark matter, formed the seeds of the first dark matter halos. These halos then attracted baryonic matter (normal matter like gas and dust) which cooled and collapsed to form stars and the first proto-galaxies. Over cosmic time, these smaller structures merge and accrete, building up larger and more complex galaxies. This hierarchical assembly process is supported by extensive cosmological simulations and observations of the large-scale structure of the universe, where galaxies are found clustered along filaments and walls, surrounding vast cosmic voids. The distribution and properties of galaxies observed today are consistent with predictions from models where dark matter provides the gravitational scaffolding for baryonic matter.