It's a common problem as the trim ages it shrinks a bit and pulls away.The original tape dries out too. The trim is attached with molding tape similar to 3M double sided tape for trim and moldings. Getting the old tape and adhesive off is a pain and takes time.A heat gun helps. The tape for that trim should be 7/8 inch wide I think, and can be found in auto parts stores , online and even in Wallmart
The old trim will clean up pretty nicely using a product like Soft Scrub with Bleach or other similar low abrasive cleaners ( maybe Barkeepers Friend, the mild version). You can wax it or apply a protectorent. Be careful not to get wax on the back. The back should be pretty clean as should the area on the boat where it attaches. Acetone will help getting the residue off. Give that a shot and see what you think. Of course you can buy new molding. Note that since the old trim has shrunk a bit, it may not reach as far as it did originally. That may or may not be an issue depending on where the ends fall.
Here is a link to the tape
https://www.amazon.com/3M-03616-Sco...eywords=3M+molding+tape&qid=1574867737&sr=8-4
Make sure you follow the instructions for the tape.