Right after the universe’s inflation, the quarks that were free because they were moving very fast due to the high temperatures bounced off each other. But after about a small fraction of a second, with the universe’s temperature cooling down, the quarks combined into protons and neutrons.