When the pedal is fully released there is a fill port open to the reservoir. The initial pedal travel pushes the piston past the fill port, which keeps fluid from draining from the reservoir.
This is how self-adjusting hydraulic systems adjust to the changing volume.
I keep reading advice to crush the hoses to keep fluid from flowing. That's long obsolete, and risks weakening the hose reinforcement fibers. This is the braking system, not a place where you want to be a hack mechanic.