Despite its look and feel, that hammer is actually a shooting weapon with range: 1. That's why you can't use it on diagonals and that's why you can destroy terrain. It's a clever use of the game's engine to do what you want despite it not really being possible.
Smashing enemies with a hammer also improves your firing accuracy
It's excellent on gals who can't aim for their life as a first training weapon.