Yes - in fact, most of the elements ONLY exist because they were formed in stars.
Scientists believe that stars contain the same elements as the solar system because all elements in the universe are created through nuclear fusion in the cores of stars. Elements are dispersed into space when stars explode as supernovae. These elements then form new stars, planets, and other celestial bodies, resulting in the similarities in elemental composition between stars and our solar system.
Elements heavier than hydrogen and helium primarily formed in the cores of stars through nuclear fusion processes. Elements up to iron are formed in the cores of stars, while elements heavier than iron are typically produced in supernova explosions or neutron star mergers. These heavy elements are dispersed into space during these catastrophic events, enriching the interstellar medium from which new stars and planets can form.
Light elements combined to form the heavier elements.
All elements up to Iron are produced by smaller stars. heavier elements (everything heavier then iron) are produced from larger stars when they go supernova.
Younger stars have more heavy elements because they form from the remnants of older stars that have already produced and dispersed these elements through processes like supernova explosions.
Oxygen and nitrogen are both produced in stars through the process of nuclear fusion. When massive stars reach the end of their life cycle and explode in a supernova, they release these elements into space. These elements then combine and form new stars and planetary systems, including the Earth.
Atoms combine to form new atoms in the cores of stars. It is possible but quite difficult to combine them in atom smashers on this planet. That is how the trans Uranium elements have been produced.
From the material of old stars.
It is not specifically those elements which "produce stars". Whatever elements happen to be around clump together, through gravity, and form the star.
Stars are primarily made up of hydrogen and helium, with small amounts of heavier elements such as carbon, oxygen, and iron. These elements are produced through nuclear fusion in the cores of stars. When a star reaches the end of its life and explodes in a supernova, these elements are scattered into space and can form new stars, planets, and other celestial bodies.
The first stars to form after the "Big Bang" were made just of Hydrogen and Helium. They were very large and died young, exploding to leave a little metal (heavier elements) in the universe - these stars are called "Population III" stars.The next stars to form incorporated a little metal from the older stars (but are still very low in heavy elements) and are called "Population II" stars. Stars in globular clusters are this sort of star (globular clusters are old and have not produced new stars for a long time). We can tell this form their metallicity and the Hertzsprung-Russell diagram for Globular clusters.Most stars contain a lot of heavy elements (high metallicity) and are quite young (like our Sun). These are called "Population I" stars.
Metals are relatively more abundant in old stars compared to new stars. This is because metals are created through the fusion of lighter elements in the cores of stars, so as stars age and go through multiple cycles of nucleosynthesis, they accumulate more metals. New stars, on the other hand, form from the remnants of previous generations of stars and may have lower metal content.