There are two main causes. The most common is from the rubber roof. If your unit has a rubber roof the sealant and outer white membrane of the roof are exposed to UV. The UV causes the rubber and sealant to dry out and start to come off with water. The best solution is to regularly clean and condition your rubber roof. There is specific product designed to help slow the degradation of the roof. EPDM roof manufacturers require its use to keep the warranty of the roof.
The second cause can be from fiberglass. If your RV has gel-cote UV has the same effects as it does on the rubber. Wax and restoring agents can help this as well.
What is a good product to use to stop this from happening. It’s ugly when it rains.
I would suggest using a rubber roof conditioner and cleaner product at least 2 times a year. Dicore makes a great product.