Nothing can be as dense as necessary for the first few seconds to have included matter. Matter can't exist at those temperatures. Atoms fall apart, neutrons and protons fall apart, quarks can't really be. Usual view is that the universe was an energy field, very small, very high energy, and the energy levels are conventionally reported as temperatures. But since temperature involves matter, it's not *really* temperature but what the temperature would have been if there had been matter. No, it's not the clearest thing--they're reporting energy densities as temperature because we have no "hook" into what the hell an energy density in an empty void.
As the energy field that existed during inflation expanded and cooled, eventually (by which I mean "way less than a second"
fundamental forces and elementary subatomic particles appeared, since energy is matter and matter is energy. When everything got sufficiently chill, what was produced was about 75% H, 25% He, and truly ridiculously small traces of Li and even smaller traces of other elements.
The theory is that the first stars formed from all that gas quickly went supernova after having produced a lot of lighter elements (stopping around iron, but with some spill over to slightly higher elements). When they exploded, that added elements heavier than H and He to the mix--and there's the first round of dust.
Second generation of stars included some of that dust, and when *they* went supernova even more heavier elements were formed. (Astronomers call all those elements metals--there's H, He, and "metals"--don't tell your chemistry teacher). And produced dust.
Neutron stars and white dwarfs would have been formed. Carbon-detonation supernovas (1A supernovas) would have produced some heavier elements, too, and neutron stars would have produced a lot of the heavier elements--gold, platinum, lead, etc. And that's more dust.
Third gen stars of sufficient size are dead and produced more dust.
Then there are stars--main sequence stars, neutron and white dwarfs--that are on rare occasion shredded by black holes. Yes, more dust.
Yet all that dust, the matter that isn't H and He and mostly in existence since the Big Bang, is maybe 1% of what's out there. All the asteroids and planets that formed and smash into each other formed from dust to begin with (yeah, yeah, dust to dust).
Stars are almost entirely hydrogen and helium, slightly tainted with heavier elements.
JWST has recently produced some qualms in the astronomy pop sci press reporting on publications about how early galaxies formed. There's a timing problem here, though. The preprints already triggered research that's posted as preprints (astro has an incredibly quick turnaround time) that showed a small tweak to the standard cosmological model can probably accommodate the observations that recently (as in last week) made it into official publication. In fact, the attitude was, "you know, we should have assumed that this would have been the case."