A sunburn is caused by exposure to too much ultraviolet radiation from the sun. UVA are long wavelengths and UVB are short wavelengths of ultraviolet light. It is not the sunlight itself that causes sunburn, but the presence and strength of the UVA and/or UVB rays. That’s why on a cloudy day you can still get a sunburn. In fact, “[a]s much as 90 percent of UV rays pass through clouds. UV rays can also reflect off snow, ice, sand, water and other reflective surfaces [including white or bright colored clothing] and can burn your skin as badly as direct” sun exposure. (MayoClinic.com)

Your body produces a pigment called melanin, which gives your skin its normal color. The darker your skin the more melanin your body produces. When you are exposed to ultraviolet light your body produces more melanin to protect the deeper layers of the skin.

https://www.empowher.com/sunburn/content/sunburn-are-you-deliberately-putting-yourself-risk