First, you dry strongly the handle, then you make a (tight) fit in the hammer, press or pound the handle in place, let it sit a while before using. The humidity comes back in the wood and makes it even more tight.
Soaking in the water is only a quick but temporary fix. You have to repair it properly anyway to keep a dependable service.
For axe, sledgehammer, pickax and others, I heat them and the handle's tip at about 80°C. Then I melt on them some hot glue to cover thoroughly the contact areas (directly from the stick) and push the handle in place. While it's hot, I put some more hot glue if there is a void.
Let it cool down and the handle will never come loose.
You don't need a tight fit, a little loose works even better. It's extremely useful for the odd shaped mounting eyes, badly casted/forged...
Easy to do, strong and reliable, but very easy to repair if you break the handle again : just heat it again and the broken bit comes right off.
Love it.