The answer is Homeostasis because your body basically says, hold up I'm too hot let me cool down. So you sweat, because the sweat cools your body down. Hence why athletes drink so much water since they heat up more easily when doing sports.
-Hope I helped, and sorry for the explanation!