I got to thinking that maybe there is a reason that witches wear such odd clothes. Maybe they have an actual need to be recognized as witches. Unusual and impractical clothing with bright colors and maybe some shiny stuff would help with that. Nobody who is not a witch would wear something like that on a battlefield.
So maybe the answer is simply that nobody shoots at people they recognize as a witch. Witches stand enough apart from ordinary soldiers and clearly visible so that they do not get shot accidentally. I mean bombs and artillery still happen but it is war. And you can have rules about when not to use imprecise weapons and when not to use witches that minimize overlap.
But why would nobody shoot at a witch that is casting on attack spell for the enemy?
Witches are simply too valuable. Valuable enough that there is a treaty that sets rules of war regarding when to use them and bans shooting at them as long as the rules are followed. This would require that the witches are really valuable during peace and very rare. Right bloodline, chosen by a familiar spirit, long apprenticeship... And a relatively stable society so that people actually care about less prosperity after the war is over.
So it would simply be sound economics not to kill witches. The enemy would just kill your witches to retaliate and then post-war everybody would laugh at how poor idiots who killed their access to magic for small tactical edge are.
Witches are magical. Anyone who kills a witch gets cursed. Basically witches do magic by mediating the power of spirits and when a witch is killed that allows the spirits to attack the guilty parties directly without having a mortal conduit limiting their power or moderating their wrath. Alternately powerful witches might simply have cast a powerful ritual magic to protect witches from angry people with fixation on bonfires. Or both of the above.
So being clearly visible would actually be a rule motivated by protecting common soldiers that otherwise might accidentally kill a witch and get eaten by a demon. That then eats anyone regardless of which army they belong to within few miles for desert. I mean why not now that it got free access to the material plane and all?
Witches are holy. There might simply be deep religious reasons not to kill witches. A witch is a bridge between the mortal realm and the spiritual realms. Or a maker of bridges maybe? In Latin that would be "pontifex" or to use more modern English form a pontiff. A witch is basically a holy person by definition.
Incidentally, people might be confused because many religions ban witchcraft and even magic entirely but this is actually bit of a red herring. In that context "witchcraft" specifically means "using magic for evil purposes" and "magic" is about dealing with "evil spirits". Or simply spirits that do not serve the will of God. Priests and holy men still would do things indistinguishable from witchcraft or magic but it would be called something else because they are not using it for evil purposes and are borrowing the power of godly spirits.
So it would be entirely possible for what is a "witch" in context of modern entertainment to be considered holy by fictitious form of Christianity or even Islam. But they'd probably call them something else and be very very clear about where the power is coming from.
The reasons are not mutually exclusive and can be combined and mixed. And probably should be. "Holy" pretty much means "mess with it and you will be cursed", so if the witches were protected by a curse, people would treat them as holy, anyway. And religious dogma and secular rules would follow.