Note: For anyone that doesn't know how air conditioning works, you'll need to visit an external resource to get all the details, such as this excellent website all about ventless portable air conditioners at: https://ventlessportableairconditioner.intervalinc.com, but if you want a simplified explanation you can read right here on this page, here it is:
Let's take a look at just why an AC needs to have a vent that extends to the outside of the building. This is important if we're to understand the working of air conditioning at even the most basic level.
Air conditioners work in a similar way to how a domestic refrigerator keeps its contents cool. The refrigeration process is the same except a fridge only needs to cool a small space (its interior) while an air conditioner needs to cool a much larger space (a room).
To do that, a refrigerant gas is compressed to reduce its temperature and air is passed through a kind of grid or radiating surface that contains the chilled gas, chilling the air as it is passed through it.
This happens at pressure and since the compressor is a mechanical device, it produces a lot of heat when it's working. That heat is combined with moisture captured from the air and expelled from the unit via a duct or venting pipe or hose.
A fridge just allows the heat to dissipate into the room it occupies, which is why you can feel the heat coming out the back of your fridge, especially in warm weather.
An AC works on a much larger scale and therefore produces a much greater volume of hot, moist air which if allowed to simply escape into the room being cooled, would actually heat it up rather than cool it because it produces more hot air than cold. That's why the heat needs to be vented to the outside of the building.
How Hot Air is Vented Outside
With fixed HVAC installations and ductless mini-split air conditioners (which have the exhaust/condenser part of the process located outside the building), the hot exhaust air is easily vented outside through a permanent vent in the wall.
You probably don't give it a second thought because you don't see it when you're inside enjoying the cool, comfortable atmosphere inside.
With portable units, there is no fixed or permanent vent. So they have a flexible plastic hose that connects to the back of the unit at one end and to a nearby window at the other end. That's what carries the hot air out of the room.
If you don't connect that hose up to a window or out through another vent hole in the wall, you'll just get hot air pumped into the room from the back of the unit and the room will heat up because there is more hot air coming out the back than cold air coming out the front!