I don't see how it can possibly be an unintended consequence or a glitch. It appears to be specifically and intentionally programmed. There is a beached fish animation that doesn't exist in any other aspect of the game. That was intentional. Further, any other time in the game when a fish is fleeing from sound or from Link, they might swim toward land but then turn before beaching themselves. I can't see any way to avoid this being specifically programmed.