They are usually held on using a stainless screw. They generally are also caulked around the underside to make them water tight.
While cleaning and revarnishing your rails in place is preferable, depending on the age and condition of you boat hand rails, you may need to do this removal. Take your time and follow the technique identified.
Hand rails, after time and use can become a source of water leakage into your cabin roof. The water may show up around the ports so you conclude the ports need the work. This is not always the case. Then of course there is the cascading affect, your hand rails start to leak, the ports start to show their age... etc. Before you know it you have a winter season of projects that gets put on hold with the virus stay home orders.
My advise, go slow with the screw removal. If the rails do chip, save the wood chips, they can be epoxied back into the rails. Use a good caulking to reattach to the deck (butyl tape works). New screws and deck hole treatment to prevent further leaks.
Before you know it you are back on the water, Sailing.