A refrigerant such as Freon mixed with a small amount of a lightweight oil (to lubricate the compressor) is compressed by the compressor causing it to become a hot, high pressure gas, this hot gas runs through a series of coils (the red coils in diagram) and with the help of the fan dissipates this heat to the outside.
In this process the freon cools and condenses into a liquid which then runs thru an expansion valve, at which point the liquid evaporates to become cold low pressure gas (blue coils in diagram). Going through another series of coils and with assistance of a second fan, absorbs the heat and thereby cools the inside of the building.
Hot air to Outside
B - Fan to help improve heat transfer from coils to outside.
C - Fan for more efficient transfer of cool air to inside.
D - Expansion Valve
E - Compressor
F - Cool Air to Inside
The cooling coils (blue) causes moisture in the warmer inside air to condense into water which drips and runs to the outside of the building, this condensation process lowers the humidity on the inside. This condensation principle is also how de-humidifiers work.
Refrigerators work on the same principle, the red portion of the coils run up the outside rear of the refrigerator and the blue portion of the coils run inside the insulated walls of the fridge. To cool down the freezer portion of the fridge cooler than the rest of the fridge, more coils are run in that area than thru other parts of the refrigerator.
This is all a basic description of how air conditioners work, in real life, thermostats are added to set desired temperature, protection devices to protect the compressor from overheating.
If inadequate or obstructed air vents on the air conditioner can cause the unit to severely ice up to the point where air flow is blocked. If this happens shut down the unit and let the unit defrost completely, sometimes you can select to have the fan to run (without running the compressor) to speed the defrost process.
Once defrosted, ensure that no blockage of air flow exists. Things like drapes or curtains that cover the inside front of the air conditioner is enough to impede air flow and cause it to ice up. A very close dresser in some circumstance can also have an effect on air flow.
For a central air conditioner, the compressor and the red coils ( as illustrated in the diagram) sit in an outside unit , the blue coils (as illustrated in the diagram) is installed in the forced air plenum of the furnace, the fan inside the furnace is used help in transfer of heat to the coils and allowing the cooler air to be forced into the interior of the house.