Exhaust gases are vented outdoors through a separate vent duct or through a separate chamber of the same pipe this requires a double wall vent duct.
Venting a gas water heater through wall.
Yes you can vent a gas fired water heater out of the wall if it is either a power vent unit.
The only other option is an electric water heater which requires no vent.
All solid liquid or gas fueled water heater whether they are tank type or tankless must vent through the roof unless they are direct vent.
Instead both systems typically expel exhaust through a pipe that runs outside through an exterior wall.
They do make two models of power vent units one is called a direct vent power vent as bob harper pointed out it draws its combustion air from outside unlike a standard power vent unit which burns its combustion air from the dwelling.
The difference is that a power vent water heater pulls in combustion air from the space.
The atmospheric water heater is very common.
The direct vent water boiler is another type of water heater venting that you should know.
Direct vent water heaters with a direct vent system air for combustion is drawn from a vent pipe that runs through an exterior wall or the roof.
Venting a hot water heater through the wall atmospheric water heater.