When overheating stops when AC is turned ON, there is likely a problem with the cooling fan system. Either one fan is not working or is not working optimally.
Just as engines overheat, it is possible to be overcooled by their cooling systems or by the inrush of environmental air passing through the radiators.
There are salient causes of overheating that are hard to troubleshoot. One symptom is coolant bubbling even before engine attains operating temperature.
Incorrectly routed drive belt that makes coolant pump to rotate in opposite direction will cause overheating. This is possible when belt of wrong size is used.
Transmission especially the automatics can overheat. The causes range from bad clutch, wrong fluid, overfilled or underfilled transmission and bad oil cooler.
Where there is no way to fix an overheating car on the spot, these are information needed to be able to drive an overheating car to a workshop or safe place.