The ball in the fish's mouth represents 'bonnō' (煩悩), bad mental states (such as greed, jealousy and ignorance) that cloud one's mind.
Hitting the kaipan helps the fish 'spit out' the 'bonnō', the sound reminding the monks of their spiritual duties.
🐉...
The layout of Manpuku-ji's structures and grounds is said to represent the abstract body of a dragon...the buildings and corridors its limbs, the paths its spine and scales, and the pond its gaping mouth.