This has to start with the principle of aircraft air conditioning.
Take A320 as an example, the air conditioning system provides bleed air from two engines or APU (independent gas turbine engine, which provides power and air source when the engine is not working). The bleed air of the engine comes from a medium or high pressure compressor. It's very, very hot because of the compressor. Before entering the air conditioning system, it needs to be precooled by the precooler and then transported to the air conditioning system.
At this time, the bleed air is still very hot, so in the air conditioning system, there are three cooling devices, two of which are heat exchangers and one is the fan refrigeration system of turbocompressor. The hot bleed air first enters the first heat exchanger to exchange heat with the ram air coming in from the opening at the muscle belly, and then it is divided into two paths. One path enters the fan refrigeration system of the next turbine compressor (the principle is complicated, so I won't introduce it here), and the other path enters the heat exchanger to exchange heat with the ram air to make very cold air, and the temperature may be below zero. Another path of relatively hot air is mixed with another path of very cold air in the next mixing device, adjusted to a suitable temperature, and then input into the engine room.
The cooling equipment used by other aircraft may be different, but basically the air bleed system provides air source for the air conditioning system, so it needs cooling.
Generally speaking, there are special cases. Such as Boeing 787. Because it cancels the air bleed system and uses ram air to input the air conditioning system. This air conditioning system is mainly for heating. Because we know that the air temperature at high altitude is low.