Battleaxe
A Battleaxe is a axe intended for battle (duh). Wherever there were trees and a need to chop firewood, people found an abundant need for axes. In a fight an axe will chop through a leg or a skull just as it would a log, so people took them along to fight. Once it was established that they were good weapons, axe-makers began made axes specifically to be weapons, tweaking the design to better serve in that capacity.
Though they have nothing wrong with swords and maces, battleaxes are the go-to weapon for your average Dwarf in most fantasy settings. Vikings also are famous for their use of battleaxes, particularly because it was the weapon commonly associated with the legendary Viking berzerkers, though again they were generally perfectly fine using swords and spears.
Battleaxes in warfare
An axe is a heavy bladed wedge of metal on the end of a handle. It does damage by swinging that bit into it's foes at high speed. On impact it delivers a lot of kinetic energy to a concentrated point with a cutting edge to drive it deep as possible. This can clop through shield, muscle, bone and armor. Even if it does not go through armor, its blunt force trauma can shatter bones. Battleaxes are great at killing people quickly, as their hits not only wound but also shock and cripple target, while mortal wounds from swords, spears or bows usually do not kill the target instantly, allowing it to strike few final blows before passing down.
The problem is that Battleaxes are cumbersome. To make them work as well as possible, they need room to get a good swing going to impact with full force. Swinging an axe at such distance also takes time. If your first strike is not lethal, your enemy has a fair amount of time to strike you while you get the next one ready. This also means that they are not the best weapons for confined quarters (for example, in a cave or a mineshaft), and it fucks up one's ability to fight in a tight formation, which was a very, very critical component of pre-modern warfare. Though if things broke down into a swirling melee, an axe-weilder would fair better.
Axes also tend to stuck inside armour, shields or just enemy chest, unlike mauls and warhammers which are also good against heavily armoured targets. An axe's pole is usually much tougher than the spear on halberd one, sometimes with a metal core(who makes this shit up?! "this wood is tougher than that wood?", "metal cores" this is some writefaggotry bullshit. Do some simple fucking research people!), and couldn't be cut by a one-handed sword, but greatswords, especially flambergers are quite capable of destroying an axe with lucky swing. That's why axe-wielders that aren't the throwaway arrow-fodder like militiamen usually carry some fallback weapon - short sword, dagger, or another axe.
Axes are also quite cheap compared to swords, though not as cheap as spears. Axe heads need much less metal than swords, but also require a good smith, unless you're pretty OK with your axe blunting after the few hits. Unlike swords and spears, axes also could be used outside the battle to chop some wood or to construct a camp. As mentioned earlier, if you are a peasant there would typically be some wood axes around if you needed a weapon and had little money. In desperate situations axe could be thrown, but unless this particular axe was designed to be thrown and the wielder was specifically trained to throw axes results are usually quite poor. However with proper training and design throwing axes are quite devastating, able to one-hit-kill or at least cripple a man even through shield and heavy armour - something arrows and javelins are unable to do.