Back on topic. Instinct has to be the result of evolution. When the first singled celled creature with a larger than normal amount of photosensitive chemicals within its membrane was alerted to an enormous amount of sunlight hitting it, it scooted away, and survived an onslaught of UV and other radiation that would have wiped it out. The single celled animals that didn't carry as much or any photosensitive chemicals would rely on perhaps the heat of the sun to warn them... and if there was very little heat but much radiation, these single celled creatures would have been wiped out.
So, we were left with (more of) the photosensitive type of single celled animal. And, what today appears as an instinct to retreat from sunlight in some animals, stems, by my reckoning, from the naturally selected, single cell animal (up to 3 billion years old) with the photosensitive advantage over those without the photosensitivity.