There is a lot of truth in this statement.
UV rays can in theory cause skin cancer but there are many many other factors that raise the risk too. Poor diet, lack of exercise, lack of sleep, stress, alcohol, overuse of cosmetics, smoking etc. And crucially spending too much time indoors!
If you block too much UV from your skin, your health will deteriorate via lack of vitamin D (which is actually a master hormone responsible for heart health, as well as bone health, it also regulates many other cellular functions in your body. Its anti-inflammatory, antioxidant and neuroprotective properties support immune health, muscle function and brain cell activity.) It’s true also that heart attacks increase the further away from the equator you go (& strokes and high blood pressure) and they increase in winter too.
UV rays also increase your bodies levels of nitric oxide which is crucial for us to regulate our blood pressure. They also raise serotonin and other happy hormones and actually protect us against certain other types of cancer.
Obviously safe sun exposure is key. Burning is always bad. But the advice to put on your sunscreen before you go out isn’t always good advice. Humans need UV on our skin for good health. We’ve been taught to fear it but we evolved outdoors.
This article explains it all
https://www.outsideonline.com/health/wellness/sunscreen-sun-exposure-skin-cancer-science/