Stars are formed from massive clouds of dust and gas in space. The time they burn for and their life cycle depend upon their size.
In a main sequence star, hydrogen nuclei fuse together to form helium nuclei.
This happens in several steps, but one way to simplify the overall change is:
Two hydrogen nuclei fuse to produce a helium nucleus and a neutron.