The phone monitors its own temperature, and if the temperature goes about the operating limit for the phone it will shut down and display a message say it has to cool off. If this doesn’t happen it has not overheated.
The phone gets warm when used, thanks to the Second Law of Thermodynamics. Anything that creates or uses energy does so with some loss. That lost energy is expressed as heat. So when you charge the phone it generates heat in the power source, heat in the charger circuit in the phone, and heat as the energy goes into the battery. The faster the charging, the more heat is generated. Likewise when you discharge the battery; not all of the energy from the battery gets to the circuits that use it. Some of it becomes heat.
If you use the cellular network for voice or data, converting energy to radio frequency signals is very wasteful; only about 30% of the energy that goes into the network components comes out as radio signals, the other 70% becomes heat. And signal strength matters; a 1 bar signal requires that the phone boost its transmitter power to maintain a connection, and it isn’t linear. 1 bar uses 10 times as much energy as 4 bars. You didn’t mention your phone model, but an iPhone 12 or newer (including SE 3rd edition) with a 5G signal uses about twice as much energy as an LTE signal, and 5G towers are still not as densely distributed as LTE, so the signal is likely to be weaker, compounding the problem.