I think that this question is why sound waves are non-dispersive whereas gravity waves on the surface of water are and also depend on the depth of the water.
In fact if the depth of the water is less than about half a wavelength, the speed of the gravity waves is $\sqrt{gd}$ and not dependent on the wavelength of the waves. The speed of gravity waves depending on the depth of the water is really no different than the speed of sound in air depending on the pressure, density etc.
Also sound waves can show dispersion as is illustrated in the article about the dispersion in concrete.
We find that at low ultrasonic frequencies the arrival velocity of
ultrasonic pulse, in such a material, increases with the grain size.
At the high ultrasonic frequencies a decrease of the pulse velocity
with frequency and grain size is observed.
In the chapter The Origin of the Refractive Index Feynman explains that electromagnetic waves interact with the bound electrons of a dielectric. The bound electrons undergo forced oscillations under the influence of the incoming electromagnetic waves. If the frequency of the electromagnet wave is not close to that of a natural frequency of the material then the dispersion is very small but near resonance the material will be highly dispersive.
So what you must look at is the interaction of the wave with the medium and its surroundings.
In the link from HyoerPhysics that you quoted you will have noted that the motion of the gravity waves are as shown below.
If the depth of water is restricted (shallow water waves) then you can imagine that the speed of the waves might well be affected.
This dependence of velocity on depth is explained in this poor video quality but excellent content Waves in Fluids which is one of a series of videos on fluid dynamics made by the National Committee for Fluid Mechanics Films.
In deep water the gravity waves do become dispersive as the phase velocity is $\sqrt{\dfrac{g\lambda}{2 \pi}}$ which depends on the wavelength.
As is explained in the video gravity waves are the result in a difference in hydrostatic pressure which causes horizontal forces resulting in wave propagation.
I am afraid that I cannot simply explain by "hand waving" why it is that longer wavelength gravity waves travel faster than shorter wavelength waves which is shown in the Ripples in a Pond video in which capillary waves are also described.
So perhaps the answer to your question is that when one starts to study wave motion the examples used tend to be relatively simple and dispersion tends not to be mentioned except in the splitting up of white light into its component colours by a prism. More advanced courses then show that the assumptions made in the less advanced course are not necessarily valid.
The book by Willard Bascom "Waves and Beaches" is available on free e-loan from Archive.org if you register with them.
Wikipedia gives a pretty much straightforward answer. In an ideal gas, the speed of sound depends only on the temperature:
$$ v = \sqrt{\frac{\gamma \cdot k \cdot T}{m}} $$
So it neither decreases, nor increases with altitude, but just follows air temperature as can be seen in this graph:
Best Answer
The speed of sound is found (both mathematically and experimentally) to be: $$ v = \sqrt{\frac{P}{\mu}}$$ . Let's understand this formula a little, it depends on pressure directly (although to $1/2$ power) means if we increase the pressure the speed will be increased because more pressure means that molecules are hitting the walls of container strongly and hence are more energetic. If we make an ideal assumption that molecules can have only the kinetic energy and no potential energy then it's a simple thing to conclude that more pressure means molecules are travelling faster (therefore hitting the walls more often and strongly) and therefore communicates or transfers the disturbance (that's what sound is) more quickly.
The denominator $\mu$ is the mass density ( you can write it as $\rho$ and simply interpret it as density), all it tells us that how bulky our particles are, if they are bulkier then it would be harder to move them and hence the transfer of disturbance will be slower because our disturbance will cause only a little acceleration in them. Therefore, our speed is inversely proportional to th square root of $\mu$.
Now, let's see your thing
See, the density means mass per unit volume, i.e. how bulky are particles in one unit volume of the medium. If they are bulkier, then they will move slowly.
There are laws for gases and which relate pressure directly to temperature like
Ideal Gas Law $PV = NkT$ .
Van der Waals Eqaution $(P + \frac{an^2}{V^2})(V-nb) = nRT$ .
For the solids, the equation changes a little, it becomes $$ v = \sqrt{\frac{T}{\mu}}$$ where $T$ is the tension under which the solid is kept. Increasing the tension increases the volume which in turn decreases the density and hence the sound travels faster. With the increase in temperature, the solid expands and hence the density goes down, therefore the wave speed goes up. This may help you.
Hope it helps.