I just learned that the Fraunhofer lines of the Sun's spectrum indicate that the Sun contains various elements other than just hydrogen and helium (for example, Na and Fe) but don't the Sun's p-p chain reactions only involve hydrogen and helium? So where do these other elements came from?
The Sun is currently turning hydrogen into helium. There are no other nuclear reactions taking place at any significant rate in the Sun. The Sun will not start to make heavier elements until it reaches the tip of the red giant branch in about 7 billion years time.
The elements heavier than helium that are present in the Sun were almost all made inside other stars. These stars lived and died before the Sun was born 4.5 billion years ago. The nucleosynthesis products from these previous stars were recycled in stellar winds, supernovae, kilonovae and novae, and then mixed into the turbulent interstellar medium.
Pretty sure from my stellar nucleosynthesis days that the p-p I chain is the dominant form of nucleosynthesis in the sun, but the p-p II, p-p III, and p-p IV chains also occur, just to a much lesser extent. Those will make Be, B, Li.
But, Na and Fe - and other heavier elements - mostly come from the sun not being a first-generation star: Previous supernovae formed those elements and they were incorporated into the sun, just as they were incorporated into Earth.
The act of fusion transfers part of atom into energy and the part left over is fused together with Hydrogen to make heavier and heavier elements. Heavier elements create more pressure in the middle of the star which creates more and more heavier elements fusing the many nuclei together. Once the sun starts making Iron(Fe), it dies and collapses which creates more elements. Or explodes if a supernova and makes gold and such. Don't know what a blackhole makes? Maybe fuses time and matter together so it can't be separated from each other.