They are attached to the forward ballast tanks. The ballast tanks are made of steel, as is the rest of the ship. But for stealth purposes, all of the exposed steel outside has been covered with a rubber compound. This rubber coating is glued as tiles, much the same as the ceramic tiles on the space shuttle are installed. The sail is no longer used for the captain to climb into and peer through a periscope.
Periscopes are now inside the pressure hull.
The sail is a free flood area where the periscopes, antennas, snorkels, exhaust, radar and other items are stored and protected. These work like the wings on an airplane. A submarine does not submerge or rise with just the ballast tanks. The fair water planes, along with the diving planes located at the rear of the ship, can be positioned up or down. While underwater, they can be used to raise or lower the bow of the ship.