An air pump prevents overheating in fish tanks by improving water circulation and oxygenation. The constant flow of air bubbles created by the air pump agitates the water surface, facilitating the exchange of gases, which helps to cool down the temperature in the tank.