Answered here.
Warhammers and axes weren’t uncommon, especially during the Late Middle Ages once armor got good enough that you couldn’t easily cut through it with a sword. In that situation, a warhammer or axe were really good at concentrating force to a point, hopefully smashing through their armor, but if not definitely knocking them down so that you could put one of these through a weak point:

That’s not to say that people stopped using swords – there’s a whole bunch of rather clever folks who’ve gone back to arming manuals to rediscover how people used half-swording and other techniques to deal with opponents in plate – but those techniques were rather advanced and involved. It’s a lot simpler and easier to grab an axe or a hammer and smack someone in the head until they fall down.