We don't know how things happened. But we have a few theories. And you know how science is always correcting itself. And enjoys it. We know that planets are byproducts of the formation of stars.