So, if normal sunlight killed mold and fungus, then we would not have mushrooms.
OK, I know, I know. That is a huge oversimplification.
Drying an item out in the sunlight is good because it might stop the
growth. Mold thrives in humidity. Not sure about fungus.** And the fresh air can improve a bad smell. But sunshine and fresh air does not kill the spores. They are amazingly hardy.
But do look this stuff up for yourself in Microbiology 101 references.
*****
** IIRC, all molds are fungi but not all fungi are molds.