How Was the Earth Formed?
Scientists believe that about a hundred billion years ago the earth, the sun, and all the planets of the solar system were nothing but a cloud of cold dust particles swirling through empty space. Gradually, these particles were attracted to each other and came together to form a huge spinning disk. As it spun, the disk separated into rings, and the furious motion made the particles white-hot. The center of the disk became the sun, and the particles in the outer rings turned into large fiery balls of gas and molten-liquid. Then they began to cool and condense and take on solid form. And at last, some four or five billion years ago , they became Earth, Mars, Venus and the other planets.
Galaxies are formed via the accretion of dust. You’ve probably seen pictures of a giant cloud of gas and dust known as a nebula. Over time various attractive forces (starting with electrostatic forces between very small particles) pull individual particles together. Everything with mass also exerts some gravitational force so this pulls larger particles towards each other which increases the mass, increasing the gravitational force, attracting more mass and so on. Once a ball of gas becomes large enough, the pressure at the centre and the resultant temperature becomes great enough to cause colliding particles to radiate energy (a proto star). Eventually it will heat up enough to initiate fusion and you have a star. A star will not use all of the material in a nebula and it blows off a fair amount in formation so there is a similar process of accretion. Planets however never contain enough mass to raise the core temperature high enough to cause fusion.