It's hard to say if the study measures sun exposure or the ability to stay healthy with a higher income & better education.
This is especially likely since, as another commenter pointed out, they corrected for wealth factors already!
Stockholm is at 60N, the university that did this study, Lund, is at 55N. If you live further south than that, you might be getting optimal, or even more than optimal, amounts of sun even without sunbathing.
https://onlinelibrary.wiley.com/doi/10.1111/joim.12496#joim1...
https://ourworldindata.org/grapher/life-expectancy-vs-gdp-pe...
> Four predetermined questions were posed regarding sun exposure: (i) How often do you sunbathe during the summertime? (never, 1−14 times, 15−30 times, >30 times); (ii) Do you sunbathe during the winter, such as on vacation to the mountains? (no, 1−3 days, 4−10 days, >10 days); (iii) Do you use tanning beds? (never, 1−3 times per year, 4−10 times per year, >10 times per year); and (iv) Do you go abroad on vacation to swim and sunbathe? (never, once every 1–2 years, once a year, two or more times per year).
I once watched a video of a medical guy giving a lecture on why people should take vitamin D supplements (he was from Minnesota, which is quite far north of the equator). He had a memorable line, "There's no such thing as flu season, there's only vitamin-D deficiency season." In the summer, he said, Minnesotans who work outside actually get enough vitamin D from skin exposed to sunlight. But in the winter, pretty much nobody in Minnesota gets enough sunlight on their skin: even if the sun is shining that day, everyone is bundled up in warm clothing!
Also, the darker your skin is, the more sun exposure you need to get enough vitamin D. So if an African and a European get the same amount of sunlight, the European's body will produce more vitamin D from it, because the African's skin has a lot more melanin. So dark-skinned people are more likely to need vitamin D supplements (whereas light-skinned people such as me are more likely to get skin cancer; there are pros and cons to having more or less melanin).
Most people, unless they live in the tropics, would probably benefit from taking vitamin D supplements during the winter. And all year long if you work indoors.
We don't get much sun up here!
If you live somewhere further south (Stockholm is at 60N, so you probably do), your milage is very likely to vary.