This animation of the diaphragm shows how it works. Gun is loaded, with no pressure. The release valve is shut. Pressure is pumped in. The two air chambers equalize, because the pressure leaks around the diaphragm.
Pressure stays in.
This keeps it sealed. Open the release valve, and the first chamber depressurizes. This sucks the diaphragm away from the barrel, so the air can escape, firing the bullet. Gun is empty and depressurized. The diaphragm is changed to a piston assembly.