This is common in any farm water system. A pressure tank is on a side branch of the line from the well to the farm water system. At the cut-in pressure the well pump starts, and pushes water into the tank until the system reaches the cut out pressure. Typically the two pressures are about 20 psi apart. There is some adjustment available.
Water would absorb air under pressure, so some mechanism is in place to regulate the amount of air in the tank. This was usually some combination of a float valve that released excess air, and a bleeder valve in the top section of well pipe that led some air back in the pipe so when the pump started, a slug of air was included. I'm sure there are other ways.
Failure of either of these would result in a waterlogged tank. The well pump would cut it, almost immediately pressureize the system, cut off, and repeat as often as several times a second. Hard on pump.
More commonly now there is either a bladder or a diaphragm in the tank to separate the water and the air. These require no additional components. Usually the tank is pressurized to about half the max pressure of the system.
I have two in my farm system, one at the house and one near the far end of the irrigation line 1500 feet away. A third of a mile of moving water has considerable momentum. My solenoid operated valves were taking a beating when turning the water off. I was popping connections from the pressure surge. Adding a 25 gallon pressure tank meant that the surge would just overpressurize the tank somewhat.
Water compressing air is used in hydraulic rams. The momentum of a pipe full of water is halted with a 'clacker' valve. The moving water loses it's momentum rushing into a air containing side chamber. That air pressure then is used to move a small amount of the water to a higher elevation. A well tuned system (Air volume, large in stream pipe, and small diameter discharge pipe have approximately equal volumes) can pump water to surprising elevations. More info here: https://en.wikipedia.org/wiki/Hydraulic_ram
water pumped air can also be used as a way to generate energy. Consider a vessel with an open bottom and two one-way valves on top. When a wave passes it compresses the air in the vessel. A valve opens and that compressed air goes to a storage tank. The wave falls, that valve shuts, and another one opens admitting air into the top of the tank.
The compressed air can then be used to operate a turbine. The efficiencies of this are low. 6 foot waves would only generate about 3 psi. There are better ways to extract energy from waves.