Correctly bled and operational hydraulic brakes have NO air inside the system.
Air is only in a bladder behind a rubber membrane. It is designed so that it cannot escape the bladder and enter the system even if upside down.
Its function is to compensate for variations in temperature because fluid slightly expands when its temperature increases. It also allows for the change in volume of the fluid system as brake pads wear.
Before riding, the brakes should always be tested whether the bike has been upside down or not. If your brakes are not fully operational it is because there is an issue in the system and it requires a service.
Here is a good site that describes how a hydraulic brake system works: