Sounds like a heat trap in the HWT, not the pipes per se. The heat traps react to small movements of water probably due to some pressure changes on the supply side to the home/apartment. There would need to be either an expansion tank or some piping that allows for enough expansion to move the ball in the heat trap.
Hammer stops could reduce it or make it worse depending on where they are located. They act like mini expansion tanks.