Water is incompressible. Flowing at speed and suddenly stopped, kinetic energy becomes a pressure wave -- up to 600 PSI in severe cases. Far more than residential pipes handle. Single bang unlikely to damage, but repeated hammer weakens joints, loosens fittings, leads to leaks or bursts. Well-established fixes, mostly inexpensive and DIY.