Stars and Solar Systems Form from Clouds of Gas and Dust.
Dust and gas are drawn together by gravity.
Gravity compresses the matter so much that intense heat develops and sets off nuclear fusion reactions. The star then begins emitting light and other radiation.
At the same time, other lumps may develop from the same spiralling cloud. These eventually gather together and form planets which orbit around the star.
The sun is in the milkyway galaxy.
One of billions of stars that form the milky way galaxy. The distance between neighbouring stars is usually hundreds of thousands of times greater than the distance between planets in our solar system.
Gravity is the force which keeps the starts together. The galaxies all rotate.