Since matter and photons were in constant contact, their temperatures were the same, a process called thermalization. Note also that the matter can not clump together by gravity. The impacts by photons keep the matter particles apart and smoothly distributed. The density and the temperature for the Universe continues to drop as it expands. At some point about 15 minutes after the Big Bang, the temperature has dropped to the point where ionization no longer takes places.
Neutral atoms can form, atomic nuclei surround by electron clouds.
And suddenly the photons are free to travel without collisions, this is called decoupling. The Universe becomes transparent at this point. Before this epoch, a photon couldn't travel more that a few inches before a collision. This is the transition from the radiation era to the matter era. The time of neutral atom construction is called recombination, this is also the first epoch we can observe in the Universe.