The essential factor to the initial formation of galaxies, according to both theories describing galaxy evolution, is:
Massive gas and dust clouds collapse.
This collapse under gravity leads to the formation of stars and structures that will eventually coalesce into galaxies.