How does a double-headed bicycle pump work
A small piston or diaphragm is centered by a light spring when pressure is equal and this allows a little air passage opening exposed on both sides. Any pressure imbalance causes the the mechanism to move slightly to one side which closes the low pressure passage and fully opens the passage on the high pressure side.
In physics and engineering this is called an unstable system, a small change cascades to a large change.
The empty tube issue was because the pressure difference was less than the centering-spring preload.
The mechanism could also be a ball rather than piston or diaphragm. Same basic concept as the piston but it uses a ball to close a hole on the low pressure side. In this case more air volume escapes from the open side so the ball gets blown over to that side and plugs the hole which causes pressure to build on the closed side and keeps the ball in place.

It is actually a pretty clever bit of kit, simple, reliable, easy to manufacture.