Every star starts out as a cloud of gas and dust, part of a larger cloud called a nebula.
For reasons which are not yet clearly understood, part of the nebula starts to contract due to its own gravity. As it contracts, it grows denser and hotter. Eventually it starts to become noticeably hotter than the surrounding nebula and to shine because it is hot. At this stage the forming star becomes known as a protostar. Protostars are usually hard to see, even though they are hotter than their surroundings, because they are embedded in the cloud of gas and dust from which they are forming.