They always have a supply of the heavier elements.
That stuff comes in the form of tiny dust particles in and amongst the gas clouds.
Eventually gravity pulls it back together; it all heats up; the dust particles melt from the heat of gravitational compaction; and suddenly it all settles out with most of the heaviest stuff at the bottom (uranium, gold, iron), and the lighter stuff at the top (silicon, carbon, nitrogen).
From that point on it just takes a bit of time to resettle more of these materials until you get a hard surface crust.
We get the rest of our iron and other heavy metals through collisions with smaller bodies ~ small planets, meteors, moons, space junk, and so on.
Sure it does!
You don't really beleive this stuff, do you?
We are literally made from the dust of stars.