When your skin makes contact with the sun your skin tries to raise its body temperature to try and keep you from becoming to hot. The skin cell start moving very fast and sometimes more amounts of melanin are produced and that causes a tan. I hope this could help you out!