This is a pretty old bug actually (This happens to me since aquatic update). Ever since pufferfish player detection contraptions were a thing, this always happened to me:
The contraption worked pefectly, until suddenly, my pufferfish died for no reason. I finally know why.
When I exit the world and reload it, there's a chance that the pufferfish phases through blocks. Making it suffocate (by block or by air).
There's also some redstone contraptions that break if the world is shut down and then reloaded, but I don't have evidence of that.
Bug Recreation video: https://www.youtube.com/watch?v=d66FU49memM