Obviously, humans can survive underwater for a short while. I've assumed this is because at some point it benefited us to stop breathing momentarily, and so we evolved a respiratory system that was able to take short breaks.
Similarly, fish can survive outside of water for a short while. However, I can't think of a single instance for most fish where they may have needed to evolve that ability. Even their ancestors originated from aquatic environments, so I don't think it's a residual ability they no longer need.
Why did fish evolve a respiratory system that could take breaks like ours can?