Hydraulic Brakes systems are not 100% sealed. They are better sealed today than in the past.
Fluid dynamics dictate that air does enter the master cylinder reservoir every time the pedal is pushed to activate the brakes. When the pedal is released air escapes the master cylinder as the fluid retracts.
This is a simplification of a complex work cycle in a complex engineered system.
To have a 100% sealed system would require the system have a fulltime pump and valve spool system to reverse the fluid flow.
Air entrance into the fluid happens several ways even in a properly maintained system. Cooling in high heat system cycles can entrap air in fluid. One of the many reasons why periodic fluid changes are needed.