There are many nuances and people seem bad at understanding those. Too many are getting their information from "health influencers" and 30 second videos, which is why we seem to bounce between the two extremes of "everyone should take Vitamin D!" and "Vitamin D is overrated!".
Australia has tried to explain sun safety here, taking into account that Vitamin D is best obtained from sunlight:
https://www.cancer.org.au/cancer-information/causes-and-prev...