Stars are big balls of gas, and they shine because the gas inside is so hot that it causes nuclear fusion, which is the energy releasing process that people can see from earth. Nuclear fusion is where two individual atoms fuse and form a different atom.
All stars are formed from the dust and gas that are within the galaxy. The gas is pulled together by gravity, and as more of it is pulled closer together, it begins to spin. This spinning causes the gas atoms to bump into one another, which creates friction or heat energy. The heat energy gets hotter as the cloud continues to spin and then it begins to glow when nuclear fusion happens. At that point, it is known as a protostar because it can still grow. It grows by attracting more gas to it. Once the star stops growing, it becomes known as a main sequence star and can shine for millions of years or more, depending on its size.
Once the nuclear fusion process has used up the energy of the star, it will shrink because gravity pulls all of the materials closer together. At that point, it is called a white dwarf, and it can stay that way for a long time. However, once it stops producing any light at all, it is called a black dwarf, and then will stay that way forever. It can no longer have gas pulled into it.