Why swords used to be the most common weapon?
They weren't. The most common weapon on battlefields was likely to be spears, pikes and similar polearms. Swords tended to be confined to the social elite, and thus the number of men wielding a sword was smaller.
I mean in all historical or fantastic movies everyone uses swords, all historical heroes are portrayed as holding swords, all idioms concerning war has the word "sword" in them.
Like I said, it's the gentleman's weapon. Anyone intending to do real work would likely have tooled up with a pike and kept the sword purely as a backup.
But when i come to think and compare the swords with maces, spears, polearms or axes i strongly think that all of these weapons would prove superior to swords.
They all have different uses and different situations in which they are useful. Maces are good against armour, especially chain, since they utilise blunt trauma to do damage rather than relying on penetration. The only useful protection against a mace is shock-absorbent padding. Axes too are more effective against certain armours (the blade usually allows for more force to be transmitted down it that the average sword, giving a cleaving like effect), plus it would also be something most people owned (not necessarily as a weapon, but you need something to chop up firewood). Polearms were usually intended for use against cavalry, but thanks to the long reach they're a good defensive weapon (one of the reasons they remained in use until the bayonet. They could not only keep cavalry and infantry off musketmen, but could do so at a length which still allowed the muskets to fire into the opposing unit without too much worry of hitting their own men).
Ironically, a sword is probably better against polearms than anything else (if you can deflect the weapon head and get behind it, then what your enemy has amounts to a big stick). It wasn't just battlefield ability which made it popular however - most swords can be comfortably carried while walking around a town or similar, (imagine spending all day carrying a halberd or the like) and could be employed in self defence against would be muggers and the like. Of course, this kind of useage eventually led to the rapier and similar designs
Maces or hammers would prove far more superior than swords against armors. And all of these weapons have a much more momentum than swords, swords are just long blades and their gravity centers arent on the point which makes contact with the target which i think renders them fairly useless. Is is only because they can be thrusted?
Armour wasn't present in great quantities on the medieval field of battle. Most combatants would be wearing no or light armour (even a chain shirt would be out of the spending range of your average peasant), thus the sword was still highly useful. In terms of combat, the sword is probably easier to use and puts less of a danger on the wielder (less recovery time after a blow). You'd need to talk to a sword wielder for that one though.
Than why? Or people were just not that clever?
They didn't dominate the battlefield at all, except in the hands of cavalry (who's dominance was due to mobility rather than weaponary, lance armed knights aside). It's more to do with the romantic image a sword wielder has in the modern day (i.e. from the sword being associated with nobility).
I myself wonder why flails are so little used, sure they arent swords and are clumsy to use but properly used they should be able to inflict good pain at least in the enemy heh.
Most flails are simply slightly more dangerous whips (and of course, as difficult to use as one, with a danger to an unskilled wielder). They wouldn't be hugely useful against armour, nor would they be much of a danger to an opponent who knew what they were doing (probably scary as hell to one who'd never seen them before though). Oh, and they're not good weapons for using from horseback.