How ocarinas produce a tone
Unlike the majority of wind instruments, such as flutes, reeds, brasswind and pipe organs,
Instead, they rely on the same physical principle of an open bottle: when one blows across its neck, the air inside the bottle acts as a spring, which oscillates at a very specific frequency. This spring can be put in motion by moving the air column in the neck, which acts as a mass connected to the spring.
Therefore, tone frequency is influenced by geometric parameters (such as volume of the cavity, shape of the neck and surface of open holes) but most crucially by blown air pressure. This is the main difference between tubular- and vessel-shaped instruments: the intonation of the latter is heavily dependent on the blowing pressure of the player, while the former is not (ideally).
The drawback is that there are more degrees of freedom in how bad one could play it; the advantage is that a well-trained ear can tune it in a quite flexible way, and one can also bend the ocarina towards their neck and blow lighter to produce an out-of-range B4 (for a Do3 ocarina).