What stops water from a moon pool from filling the inside of a submarine?
The air is stopping the water from coming inside.
For the water to enter a cavity already filled with another fluid, it has to either displace or compress this fluid. The shape of the container prevents the air from escaping and the water can't rush in if the air inside is at the same pressure as the water outside, because then the net force on the interface is zero.
Air pressure is what holds back the water. If the air pressure is higher than the water pressure the water cannot enter. Typically it will just be a pressurized chamber - not the whole sub.
As someone else has said, the air pressure is what prevents the water from entering the submarine. But let's do some calculations.
We will assume that the robustness of the hull is not a problem, i.e. the hull of the submarine can withstand infinite pressure$^1$.
The pressure inside is initially $P_{atm}=1$ atm. The pressure outside (water pressure) can be computed from the hydrostatic equation:
$$P_{out}(z) = P_{atm} + \rho g z$$
Let's assume that the air inside can be approximated by an ideal gas; we will then have
$$P_{in} = nRT/V$$
whre $V$ is the volume of air inside the moon pool chamber. We will also assume that the internal temperature $T$ is kept constant by a very efficient air conditioning system.
With the submarine design you show, mechanical equilibrium requires that
$$P_{out}=P_{in}$$
from which we obtain
$$V(z) = \frac{nRT}{P_{atm}+\rho g z}$$
The initial volume is
$$V^*=\frac{nRT}{P_{atm}}$$
from which
$$V(z) = V^* \cdot \left(1+\frac{\rho g z}{P_{atm}}\right)^{-1}$$
This equations tells us how the volume of air inside the chamber decreases with depth.
For water, we have $\rho=10^3$ kg/m$^3$ and this value can be considered independent from $z$ since water is almost incompressible. Atmospheric pressure is $P_{atm}=10^5$ Pa. We round up $g$ to $10$ m/s$^2$. Therefore we obtain
$$V(z) \simeq V^* \cdot \left(1+\frac{z}{10 \text m}\right)^{-1}$$
At $10$ meters deep, $V \simeq V^*/2$.
At $20$ meters deep, $V \simeq V^*/3$...
You can see that very soon the room will be completely filled with water. In order to prevent this, it must be pressurized, and this requires the use of an airlock. But even like this, the pressure in the chamber cannot be increased too much, otherwise those who enter will risk oxygen intoxication.
$1.$ This is not such a bad approximation as it seems. Modern nuclear submarines can go as deep as $730$ m before the hull collapses, withstanding a pressure of $74$ atmospheres. A submarine with a hole in it will be filled in water well before the hull collapses (see above discussion).