The sun formed more than 4.5 billion years ago, when a cloud of dust and gas called a nebula collapsed under its own gravity. As it did, the cloud spun and flattened into a disk, with our sun forming at its center. The disk's outskirts later accreted into our solar system, including Earth and the other planets.
How Sun is created?
The Sun and the planets formed together, 4.6 billion years ago, from a cloud of gas and dust called the solar nebula. A shock wave from a nearby supernova explosion probably initiated the collapse of the solar nebula. The Sun formed in the center, and the planets formed in a thin disk orbiting around it.
What is the sun made out of?
The sun is not a solid mass. It does not have easily identifiable boundaries like rocky planets like Earth. Instead, the sun is composed of layers made up almost entirely of hydrogen and helium.