Most things in the universe happened to slowly for us to see them happening stars, like the sun take tens of millions of years to form and hundreds of millions of years to orbit there galaxies and colliding galaxies take billions of years to merge and yet we have a pretty decent understanding of how all these things happen because there are so many of them in the observable universe that we can look out and see different versions of similar events happening in different places and because light takes time to get here we see places at different distances at different times throughout the history of the universe. And from all that we can piece together an understanding of how stars are born and how they died how galaxies develop an interact and so on it’s kind of like if you only had 10 minutes to study how humans grow you couldn’t see any one person grow very much in that time. But by looking at humans of different ages all around the world, you can get a pretty good picture of what a human life looks like. However, the very first galaxies to ever form were so small and dim that we don’t have nearly as good an idea of how baby galaxies are born as we do about how they behave and interact later in life. Life our current understanding is that in the early Universe before any stars had formed everything was just spread out gas and a lot of Dark Matter dark matter is matter that doesn’t interact with things other than by gravity so we count dark because we can’t see it gravity would have caused slightly denser areas of dark matter to attract into clumps pulling in bits of gas until they were dense enough on their own to gravitationally collapse and start thermonuclear Fusion a star many stars clusters of stars and their Associated Dark Matter attracted together and merge
And then those clustered clusters clustered together eventually forming the most distant and longest ago galaxies. We see today, but we don’t know exactly how soon after the big bang the clumps of dark matter and gas formed or when during the process of clumping and clustering the first Stars ignite it or if there was a minimum Dark Matter Clump sighs necessary to attract enough gas to form stars or if the very 1st star clusters came together to form galaxies at all. They might have been so small and fragile. They were blown apart when their own Stars went supernova and the first galaxies He’s may have actually formed from a second round of clumping of gas and dark matter as well as dust from the explosions. To be honest. We don’t even have a good enough definition of what a galaxy is to know when to stop calling something a cluster of stars. And when to start calling it the Galaxy what we do know is that today? We have bajillions of galaxies in our universe. None of which existed 13.8 billion years ago. So somewhere in between, they must have all been baby’s big gassy babies surrounded by clumps of dark matter