Does the Sun have the same composition and density everywhee within it? How does it vary in other stars?
No it does not have the same composition everywhere. In the core hydrogen is fused into helium, so the fraction of hydrogen (denoted by $X$, between 0 and 1) decreases while the fraction of helium ($Y$) increases as time goes by. There is not much exchange of matter between core and envelope so the envelope will essentially have the same constitution as when the Sun formed.
In other stars the convection zone extends into the core, and for these stars there will be more exchange of the different elements within the star.
Evolved stars (e.g. red giant stars, horizontal branch stars) often have multiple shells where different nuclear fusion processes occur. An Asymptotic branch star, for instance, has a carbon-oxygen core surrounded by a helium burning shell, surrounded by a inert helium shell, surrounded by a hydrogen burning shell, surrounded by a very large envelope consisting mostly of hydrogen.
For non-degenerate matter density depends on the pressure. The deeper you descend into the star, the higher the pressure and therefore the higher the density.
No, the sun and all other stars do not have the same composition and density within them.
The composition varies with depth. Most stars overall composition reflects the interstellar medium from which they form. Convection, settling and nuclear processes then lead to layers of different elements at differing depths.
Fusion occurs at the core of our sun (where pressure and temperature are greatest) therefore there is a greater abundance of Helium at this depth (through conversion of hydrogen). Other stars that have entered the red giant phase will also have many more heavier elements. Very late stage stars are thought to fuse these elements progressively, leading to layers of decreasing atomic number elements stacked on top of each other.
Convection can also lead to mixing of elements between layers. The diagram below shows theoretically how these convective layers differ over a range of stellar masses
The density increases as you move closer to the center of the star. Note how the density is less than that of water for up to half the sun's radius!