One interesting wrinkle is that if you take linear gravity, gravitationally-bound structures don't change over time.
Actual General Relativity isn't linear at all. But you can take a simplification of General Relativity, where you have some average density and small differences from that average. This allows you to decompose the system into linear terms and non-linear terms. If you include only the linear equations, then the result has a lot of nice mathematical properties that make it easy to solve equations. And the result is accurate for the initial stages of structure formation, and remains accurate for very large scale behavior.
The picture that is painted is that we have a universe which was, in its early phases, far more dense. But some parts of the universe were more dense than others. As the universe expanded and the rate of expansion slowed, the expansion of the more dense systems would have slowed to the point that their expansion could be halted entirely. They form bound systems. And those bound systems, according to linear theory, don't change at all from then on.
Now, as I mentioned, linear theory isn't accurate at small scales. If it were, we couldn't have any galaxies. But it still provides a first-pass look at what is going on at big scales. It paints a picture where early-on, the structures don't so much form as become distilled out as the less-dense regions continue to expand. As the low-density regions expand while the more dense regions change very little, the structures become more and more apparent, because the density contrast between the more-dense and less-dense regions grows. So you can imagine that early-on, there wasn't much difference between the more-dense and less-dense regions at all. But as the less-dense regions expanded and the more-dense regions remained comparatively static, that density contrast really becomes striking, and it forms shapes very much like you'd expect from a bunch of touching soap bubbles.