And reflecting on you mentioning the big bang, why don't we dive into that too?
No I'm just kidding its too complicated to be discussed here and no-
OK FINE!
So before the 'BiG bAnG' all of the energy and spacetime was in a 0 dimensional point, and as it 'expanded' there was no bang. It was just spacetime expanding into itself with energy filling it in in every direction. (This expansion still continues today.) There was no matter, as you correctly implied, but there was ENERGY! What did you just ask, how many energy was there?
YES.
ALL OF IT.
So much that it was too much for even matter to form for a fraction of a second. But then after 1 second, after quite a few quantummechanical processes, almost all of the matter was formed, first just the stuff that makes up p+ and n0, then those heavier particles above were formed, along with as many e- as p+. This is called bariogenesis and for some reason after every 1 billion matter and 1 billion antimatter particle, 1 additional matter particle formed, and this is why not all of the created matter was annihilated in the universe. This tiny asimmetry allowed all the things that exist now. But there were no atoms, just nuclei and electrons, as the universe was still so small and dense for nearly 300,000 years that no photons could form, and that prevented electrons from going to a lower energy state around a nucleus, because they would get rid of that extra energy by emitting a photon. For 3*10^5 years, the universe was DARK. Then all the fun stuff happened like staaaars aaand gaaalaaaxiiieees aaand whaaatnoot but you already know that.