The chemical elements composition of the sun changes as its nuclear furnace changes elements into heavier ones. But it is supposed to be mostly Hydrogen at the start. The planets are too cold for such chemical composition changes, and contained initially the heavy elements composing them (up to contributions from various objects such as comets and meteorites, which may have contributed to all bodies of the system, and come from the same initial cloud).
Both the sun and the planets were created from the same cloud. Thus why is there such a difference in composition.
My only explanation is that only the sun was massive enough to retain an hydrogen atmosphere, most of what hydrogen was available, while smaller planets tend to lose their gaseous atmosphere, and that the sun does contains also heavy elements, in small quantity compared to the hydrogen it captured (to limit its effect on the sun nucleosynthesis).
Does that imply that the planets are to be expected to have roughly the same proportion of the different elements? ... of course not necessarily assembled in the same molecules.