I like your curiosity and logical thinking - you're just missing a few pieces of the puzzle.
The sun emits ultraviolet light radiation which is the component of sunlight that is able to damage skin.
Ultraviolet (UV) is a form of electromagnetic radiation with wavelengths between 10 to 400 nanometers, shorter than that of visible light but longer than X-rays. To put nanometers into perspective - A human hair is around 75,000 nanometers in diameter. There are sub-types of UV which define the wavelength size:
- Ultraviolet A - UVA - 400–315 nanometers
- Ultraviolet B - UVB - 315–280 nanometers
- Ultraviolet C - UVC - 280–100 nanometers
Interestingly UVB is essential synthesize Vitamin D.
UV light is able to damage DNA. This results with humans cells (typically skin cells) to attempt to repair themselves. As a result sometimes genetic mutations arise - some of which give the cell the ability to divide more frequently (cancer). The process of UV damage is shown in the image below.
Although advertises I'm sure would love you to believe that Vitamin D should always be gained from their supplement, the world health organisation states the following "...5 to 15 minutes of casual sun exposure of hands, face and arms two to three times a week during the summer months is sufficient to keep your vitamin D levels high.". Yes I understand - supplements avoid aforementioned damage to DNA - but you will be safe if you follow the above directive (it's free) and learn more information on other methods to prevent damage when in situations of long-term exposure.
In terms of further scientific reading I would like to direct you toward higher quality literature. This web-page explains the difference between and the best information resource out of: News articles, Journal articles and, Peer-reviewed scientific articles. In saying this, I also think Wikipedia in the 21st century has gained a highly respected and excellent reputation for free high quality information.
Attached is a Chloropleth map displaying the total average daily ambient ultraviolet radiation (UVR) level across the world.