Since stars form in explosive events, it seems painfully obvious that some of the shit that comes flying out does not stick around, and that it could be planet sized/shaped.
Stars are formed in nebulas of gas and dust via gravitational collapse (accretion).
The remaining gas and dust that is swirling around the star flattens out into a disk (because of angular momentum). Planets gradually form in this disk, again via accretion (snowball effect).
The remaining gas and dust that is swirling around the star flattens out into a disk (because of angular momentum). Planets gradually form in this disk, again via accretion (snowball effect).
https://en.m.wikipedia.org/wiki/Protoplanetary_disk
https://en.m.wikipedia.org/wiki/Accretion_(astrophysics)