Why exactly is it recommended to store cooking oil away from sunlight? How does sunlight accelerate spoilage?
The main enemy of oil is oxidation, which is the reaction of the constituent molecules with oxygen. How fast oxidation occurs will depend on the type of oil you consider. For example, unsaturated fat oxidizes faster than saturated. Therefore oils with higher content of unsaturated fat tend to oxide faster.
Since oxidation is a reaction, it changes the chemical content of the oil. Oxidation is measured in the industry by looking at the molecules that were not there originally. More specifically, they differentiate primary, secondary and tertiary oxidation, each associated with the presence of certain subproducts of oxidation, in increasing order of complexity.
The fact is that if you go to the lab and take two samples of the same oil, leave it in the same room for the same time, one protected from sunlight and the other exposed, and after you measure oxidation according to the criteria aforementioned, you will observe that the exposed oil will have a higher concentration of secondary oxidation chemicals than the protected one.
Oxided oil might not be completely spoiled, but it definitively changes some of its 'nice' properties.
The crude underlying reason is the photoelectric effect: light can excite electrons and make molecules more reactive. If you are interested in more chemistry details I would recommend reading this paper or this simpler one, that explain also the role of other factors such as humidity, temperature, etc.
Both heat and short-wavelength light (blue and UV. Plenty of that in sunlight - enough to degrade some plastics rapidly) tend to accelerate chemical reactions. Degradation of fats is a slow chemical reaction...