I see quite a bit of sense, if not textbook 'logic', in how these punishments are determined.
See, the being assigning the punishment is opinionated, emotional, and usually no more logical than the next dwarf.
The creator of the punishment is SO impulsive about it, the beard doesn't even verify that hammers or cells exist in the fortress before assigning punishments involving them. Kinda like a judge trying to send someone to the (non-existant/never-gonna-exist) penal colony in Antartica, or the one on the moon. There's no oversite committee to say 'hey, we cant do that, so how will we punish them instead?'
So, the beard's thinking in the moment, how upset is he about what's gone on? How vile does he currently imagine the prison to be, how nasty and heavy the hammer? Is he mad enough at someone he wants them dead, or just inconvenienced? After all, the nobles rarely visit the prisons.
So the first time, the leader was thinking the prison was fairly dangerous and definately unprovisioned, and imagined the hammer as something fluffy and padded. The second punishment he was thinking roughly the opposite, with that hammer having spikes of hammers which themselves were spiked with hammer-spiked hammers, but the prison must be some unused bedroom somewhere back behind the drink stockpile.