Boxers who die in the ring or shortly after usually either: didn't have enough time to rehydrate after cutting weight, were fighting too soon after taking a lot of damage, or were in a too-long fight. In almost all cases they've been failed by their corner, and often the commission.
That explains why they die, but not how they kept going when they were dying. I always remember the Nigel Benn/Gerard McClellan fight when he was touching his head after being stopped, and then collapsed in the corner.