If you compress a gas, it gets hot. A bicycle pump is a good example - you can feel it getting warm as you pump up the tyres. The compressed gas is passed through a radiator, like on the back of your fridge, to get rid of the unwanted heat. You can feel this heat in the exhaust air from an air conditioner.. Now, if you allow the gas to de-compress, it gets cold. Discharge a carbon dioxide fire extinguisher, and the gas coming out can cool the nozzle enough to give you a 'cold burn'. In the air conditioner, the compressed gas flows through a fine nozzle and loses pressure. The now cold de-compressed gas passes through another radiator, that cools the air round it, and a fan blows the cold air into the room.
An alternative in a heatwave is to have a fine water spray covering your house - though the water company might have something to say about that!!