You're correct that heat naturally flows from a higher temperature region to a lower temperature region. This principle is known as the second law of thermodynamics. However, refrigerators work by exploiting the process of heat transfer and using it to create a cooling effect inside the fridge.
The basic principle behind how refrigerators work is called the vapor compression cycle, and it involves four main components: a compressor, a condenser, an expansion valve (also known as an expansion device), and an evaporator. Here's a simplified explanation of the process:
Compression: The refrigerant, a special fluid with low boiling and condensing points, is compressed by the compressor. As it is compressed, its temperature and pressure rise significantly.
Condensation: The hot, high-pressure refrigerant then flows through the condenser coils located on the back or bottom of the refrigerator. Here, the refrigerant releases heat to the surrounding environment (your kitchen) as it condenses into a liquid due to the high pressure and lower temperature outside the fridge.
Expansion: The high-pressure liquid refrigerant then passes through the expansion valve, where it undergoes a sudden pressure drop. This causes the refrigerant to rapidly expand and turn into a low-pressure, low-temperature mixture of liquid and vapor.
Evaporation: The cold refrigerant mixture now flows through the evaporator coils inside the fridge, where it absorbs heat from the interior of the refrigerator compartment. As it absorbs heat, the refrigerant evaporates, turning back into a vapor.
This cycle repeats continuously, ensuring that heat is continuously removed from inside the refrigerator, keeping the contents cool. By transferring heat from the interior of the fridge to the surrounding environment, the refrigerator maintains a lower temperature inside, allowing it to preserve food and beverages.
So, even though heat naturally flows from high temperature to low temperature, refrigerators utilize a controlled process to transfer heat from inside to outside, creating a cooling effect inside the fridge.