For matter to avoid falling into a star, it had to have sufficient angular momentum to orbit it, forming the accretion disc from which planets coalesced.
Wherever there was a concentration of matter, gravity tended to pull it closer together, and eventually the first stars were formed. We know from the cosmic microwave background that the distribution of matter wasn’t uniform – if it had been, the universe as we know it wouldn’t exist. After the big bang, matter moved away from its origin at high speed. Guy Cox, St Albans, New South Wales, Australia The change in spin radius as a vast molecular cloud collapses into a star is so enormous that an imperceptible spin in the cloud manifests itself as a spinning solar system with planets orbiting a star. This is due to the conservation of angular momentum, observed when a figure skater spins faster as they pull in their arms. However, when one atom doesn’t fall towards the very centre of the well, it produces a tiny torque, which becomes accentuated as the clump of matter collapses.
If these potential wells and all the matter falling into them had all been perfectly spherically symmetric (that is, symmetric along any axis) then there would be no spin. Clumps of dark matter formed first, and acted as “seeds” for the formation of structures, providing gravitational potential wells that pulled in atoms of normal matter.