How does refrigerator actually work?
Refrigerators work by exploiting some properties of compressible gases.

To simplify greatly, gases tend to heat up when they are compressed and liquefied. And, when the liquid revapourises this process absorbs energy. |In a refrigerator those two processes are physically separated and this enables the transfer of heat from one place (the inside, which gets colder) to the outside (which gets warmer).

The way this works in a typical refrigerator is to have a compressor on the outside of the cold area that takes gas and compresses it while letting the extra heat dissipate into the outside environment. This combined process of compression and cooling (or, more accurately shedding the extra heat generated by compression) liquefy the gas. This liquid is then allowed to flow into a heat exchanger on the inside of the refrigerator where it is allowed to evaporate. This evaporation absorbs energy from inside the fridge making that environment colder. This gas is then allowed to flow into the compressor, completing the cycle.

This allows the fridge to convert mechanical energy in the compressor into a clever way of transferring energy from the inside of the fridge to the outside. This amounts to exploiting a phase change in the refrigerant into a pump that moves energy from cold to hot. Though this only works because we can separate the inside from the outside thermally enabling the two side of the process to behave normally (heat flows from hot to cold on both sides) but the net flow ends up taking energy from cold to hot by exploiting the energy used to cause a phase change in the refrigerant.