Why will a pipe hold water pressure, but not air pressure?
Water is approximately 200 times denser than air so the very tiny leaks that can allow air to escape are too small for water.
In industry we do similar testing with less dense gasses like helium to see if it will leak as air is denser so if the helium is leaking below a specific rate we know it won’t leak air.  Check out helium leak testing if interested.