Video: Where do galaxies come from?
A video suggests that before any stars had formed, everything was just spread-out gas and dark matter. Gravity would have caused slightly denser areas of dark matter to attract into clumps, pulling in bits of gas. Clusters of stars and their associated dark matter attracted together and merged, and then they gathered together, eventually forming the galaxies we see today.