Ours rusted and came loose the same way.
There are a couple different resources to buy new seals, I have one listed below.
We did not replace ours, we used 3M Black Weatherstrip Adhesive. It comes in a tube and works well. We pulled the trim away a little wherever it was loose, then put a bead of adhesive into the groove of the rubber trim, then reattached it to the wall of the coach. It has been on about 8 months now with no problems.
BE VERY CAREFUL: this stuff is black and sticky, it doesn't remove very well if you spill or ooze any out of the groove.
https://www.pellandent.com/RV_Produc...CategoryID=173