Supernovas are the sole source of every element out there heavier than iron, and most of everything other than hydrogen and helium. Clouds of matter come together to form planets over a very long time scale because when all there is is a big cloud, the gravitational attraction between molecules and atoms is enough to "condense" them into solids. We do still pick up trace elements from space, but most of what's here is from the formation.
Formation and evolution of the Solar System - Wikipedia, the free encyclopedia gives you a good idea of the basics.