The standard theory is that planets formed out of the accretion disk around their sun. I don't buy it. My conjecture is that virtually all planets and even most larger moons are the cores of dead stars after their outer layers have blown off and they have been captured by newer, younger stars as galaxies have collided and passed through each other. Now there may be a little evidence to support my conjecture.
A few years ago I was reading up on stellar evolution and how uranium and other heavy elements are created. One of the facts I uncovered is that fusion in a star normally leads up to the production of elements only as heavy as iron and nickel and after that stage the fusion process consumes more energy than it produces, so normal solar fusion cannot produce heavier elements such as gold, lead, or uranium. Only much larger stars which end up as supernovas can produce the energy and pressures needed to form the metals heavier than iron and nickel as they explode in their death and produce such enormous temperatures and pressures that even the heaviest of metals can be produced.
After thinking about that for awhile I realized that the core of the earth is predominantly iron and nickel, the same as one would find at the end of life of a moderate sized star. I also realized that our own gas-giant planets are composed predominantly of the lighter elements that one would just so happen to find in the cores of smaller stars at the end of their lives (carbon, oxygen, nitrogen, and silicon, but not iron and nickel.)
So, I formed my conjecture that the planets are really the cores of "dead" stars that have merely been captured by their "sun" as galaxies collide and pass through each other rather than "accreted" from the same disk as the sun.
In fact, I further conjectured that the smaller, more rocky and more metallic planets originated as the cores of larger stars after they had near-supernova deaths that blew off their gaseous outer layers, leaving a collapsed core primarily of iron and nickel plus, gold, lead, uranium and other heavy metals that were produced in a supernova-like process that wasn't quite strong enough to blow the atoms far enough apart to prevent re-collapse to an earth-like core.
So, that was my conjecture, but of course I could not prove it.
Now, I read that scientists have discovered earth-like planets orbiting very old, metal-poor stars that couldn't have had all these heavy metals in the star's accretion disk before there had been supernovas.
So, maybe my conjecture still has some potential.