Recurring banging in water pipes, cured by draining system
It's called "water hammer", and it's caused by the physical momentum of the water in the pipes being dissipated when the flow stops suddenly.

By draining the system, you're creating an air bubble somewhere in your plumbing that provides a cushion for the momentum, eliminating the banging, but this bubble is leaking away somehow, which causes the banging to resume.

A permanent cure would be to connect the bottom end of a vertical pipe that's a few feet long to a point near the service entrance in your home. Make sure the pipe is full of air and cap off the top end permanently. This will provide a permanent air bubble that should eliminate the banging for good.