Stars are formed, or are "born", in large clouds of gas and dust. The cloud slowly shrinks and then starts to collapse onto a number of points (or cores) within the cloud, all due to the pull of gravity.
Right in the middle of these cores, it can get very hot and dense. When this happens, nuclear fusion can start and a star is born. This is called stellar ignition.
The sudden burst of light made by the new star blows away much of the nearby gas cloud, but it can leave just enough material behind to form a number of planets later on.
You can see what is happening in a bit more detail in this simulation.
At this point the star becomes relatively stable, with the outward pressure from nuclear reactions balancing the inward pull of gravity.
A typical star like the Sun will live for around 10 billion years, until it eventually runs out of fuel. All stars go through a life cycle in the same way that we do - they just live longer. When they eventually run out of fuel, they will end their days in spectacular fashion.