Does skin cancer come from the Sun ☀️ or chemicals?

Rather than focusing on health disadvantages, I want to know WHY! Is sunlight truly dangerous for us? What types of chemicals does our skin absorb from shampoos, body wash, lotion etc.?