Hi Alex
Very Unlikely to have moisture damage! You can stick it under water (6 meters) for 30 minutes. IP68 rated. I still won't recommend you test this, but splashes and a few drops into shallow water hasn't killed my 13+. Look at all the stories about iPhones lost in oceans, lakes and rivers for months and they still work fine. Seriously folks, modern iPhones can handle minor water encounters just fine.
I think it was due to some iPhone internal processing going on.
Have you tried shutting down the phone, wait a minute or two then restart phone? It might be possible that some process has become corrupted, so shutting down (Power off) may clear the problem. Shutting down and restarting an iPhone is good place to start troubleshooting problems.
Did you recently update the iOS? If you have automatic updates on, then your phone may have updated. After updates, iPhones do this massive local on board analysis of various apps like photos and data that often causes CPU activity for short intensive time periods. This can cause overheating. Try leaving phone charging overnight, it might complete the processes.
A new issue is wireless charging. They do create heat so check while charging after about 15 minutes. Charging via cable is faster and produces less heat.
Having silicone cases on your phone can contribute to overheating as well as direct sunlight, heat source etc…
Hopefully, by now your phone is fine, but if not and you continue with overheating, time for Apple Store.
Hope this Helps, Greg