Moving water has mass. When a valve shuts off abruptly, the moving column of water has to dissipate its kinetic energy somewhere, in this case, transferring it to the piping. Vertical standpipes filled with air act as shock absorbers to absorb some of this energy. The bigger they are the better they work. The more the better too as they can have a collective effect if they are on the same line.