Lower temperatures mean photons with less energy and fewer collisions. Thus, atoms become stable at about 15 minutes after the Big Bang. These atoms are now free to bond together to form simple compounds, molecules, etc. And these are the building blocks for galaxies and stars. Radiation, in the form of photons, and matter, in the form of protons, neutrons and electron, can interact by the process of scattering.
Photons bounce off of elementary particles, much like billiard balls.
The energy of the photons is transfered to the matter particles. The distance a photon can travel before hitting a matter particle is called the mean free path. 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.