Your refrigerator has a compressor and a closed system of tubing that contains a gas (the refrigerant). The compressor pumps the refrigerant and compresses it. The refrigerant flows through the coils on the back or under the refrigerator and through an expansion valve to the inside of the freezer. As the refrigerant passes through the expansion valve the pressure drops and so does the temperature. Inside the freezer a fan circulates air over the cool tubing and the refrigerant absorbs the heat from the freezer's relatively warmer air. If you prefer to just think of the fan blowing cold air into the appliance, that's fine, it all works out to pretty much the same results. But technically, the heat is being pumped out rather than the cold being pumped in.
The cold air in most refrigerators, but not all, comes from the freezer. The cold air in the freezer passes through vents to the refrigerator. A thermostat in the refrigerator activates the compressor whenever the temperature rises above the set point on the temperature control. In some newer models there is a separate cooling coil for the freezer and the refrigerator and thus two temperature controls.
As the air in the refrigerator cools, the water in the air (humidity) condenses. Water that condenses in the freezer will freeze into frost. Most modern refrigerators have an automatic defroster in the freezer which prevents the build up of frost. The defroster is simply a heating element that is controlled by a defrost timer and a thermostat. The water from the melted frost drains out of the refrigerator into a pan beneath the refrigerator and evaporates.
A door switch closes a circuit when the door is opened and turns on the interior light. When the door is open some refrigerators will disable some components such as the fan, defrost heater or "through the door" ice and water dispensing.
A common question we hear pertains to operating a refrigerator in the garage or other unheated space during cold weather. Bottom line, refrigerators and freezers don't cool efficeintly when operated at temperatures below, roughly, 45 degrees (F). The first reason is that the outside temperature may get low enough that the thermostat inside the refrigerator never gets warm enough to activate the compressor and so the freezer warms up to the outside temperature. Another problem is that if it gets too cold, the refrigerant pressure becomes too low to generate the necessary cold and so the freezer only chills down to the outside temperature.