The fridge or freezer cools the air in it. This causes moisture in the air to condense.
As others have said the water drains through a small hole at the back and collects in a reservoir from where it evaporates.
Incidentally, the "drying" of the air by cooling it is why your car wibdscreen...