Magic gives the user an advantage. It allows them to attack from a distance. That creates tension, since the warriors will have to risk injury or death to get close enough to defeat the wizard. Once you introduce guns to the story, that range advantage disappears. There is no point to spend the time studying magic if a new infantry private is just as powerful as the wizard.