Firearms have been around for a long time, but they were not really effective until after the medieval era. It's kind of like with crossbows; skilled archers would outdo crossbowmen and riflemen, but crossbows and firearms are easier to use. You just pick it up and point it in the right direction, whereas archers have to be trained for years to become effective. To summerize, firearms are nice but expensive (but unreliable and dangerous, black powder explodes) short range artillery. They are however no match for a squad of skilled archers (like longbowmen).