It is thought that the primordial nucleons themselves were formed from the quark-gluon plasma during the Big Bang as it cooled below two trillion degrees.
A star gains heavier elements by combining its lighter nuclei, hydrogen, deuterium, beryllium, lithium, and boron, which were found in the initial composition of the interstellar medium and hence the star.