There are (at least) two sides to this story. One is direct DNA damage being caused by UV-B light which happens to have photons with just the right amount of energy to interact with thymine. This has been known, and assumed not just during the 80s, but until the late 2000s to be The One major thing that causes cancer, or trouble in general (there's papers from ~2008 claiming that).
Meanwhile, it is known that UV-A can excite an electron in a chromophore (i.e. some more or less random unspecified molecule, or part of it) in a way which turns out being less desirable than one would wish.
Photons exciting electrons isn't something particularly new or stunning (think photosynthesis or our ability to see), it happens all the time, almost every time a photon hits something. But some molecules react more favorably, and some... don't.
For example, melanin happens to be our "sun protector" molecule because it has the property that it almost instantly drops its excitement into heat, which is quite harmless.
Other "random" molecules do not necessarily have such favorable properties and may either form radicals or stay excited for a long time until they finally bump into something and interact with it in some way, giving off that energy in some unspecified, haphazard manner. When that happens, well, things happen, whatever they may be. The damage, finally, doesn't even have to be at the exact location where the sun was shining.