There is ultimately no problem
It's unlikely mages would be heard
You say that the enemy can hear what a mage is chanting and then act accordingly. I ask How?
Let's be clear - people speaking, even shouting, isn't THAT loud. Here is a shirt funny scene from the movie Shazam:
Dr. Sivana (antagonist): Enough games, boy. You think a pack of children can...
[Dr. Sivana speaking faintly in the distance]
Shazam (protagonist): Wait, what?
[Dr. Sivana] You will beg for mercy as I feast on your heart... slow.
[Dr. Sivana continues speaking faintly]
Shazam: Are you making some big evil guys peech right now or something? You're, like, a mile away from me right now. There's cars and trucks.
Dr. Sivana: I will have the world eating out of the palm of my hand...
Shazam: All I see is mouth moving. I don't hear any...
Dr. Sivana: I have the power to unleash...
Shazam: Ah, whatever. Screw it. [Flies forward to attack]
This is a funny moment in the film but it showcases that it's not that easy to hear what somebody would be chanting. It becomes especially hard if there are other people around.
Here is footage from the game Ultimate Epic Battle Simulator. The name is a bit of a joke but it allows you to deploy a variety of units in a battle and see what happens. It's not too realistic - there aren't many tactics or strategy but at least it makes for entertaining watch:
You'd notice that the armies are loud. Were there some make standing slightly behind one group, do you think the other group would hear exactly what the mage said?
Here are some scenes from movies:
I don't know exactly how accurate these depictions are but I'm focusing on sound. My guess would be that a battle would sound similar. In that it would be loud and chaotic. And those are middle age battles. Here is an early modern battle from 1653
It's louder. A lot louder. Because there are cannons. Mages throwing fireballs and other spells are likely to produce similar level of noise perhaps even more. It would make it very hard to hear what they are actually chanting from the enemy.
It's easy to obscure them
Even with all the noise and chaos of battle, what if the enemy can still recognise what the mages are casting? Well, it's super simple to further obscure the mages:
- block vision to them - just put the mages in a tent or even simpler - a sheet in front of them held by two polls. Done, now the enemy cannot see the mages.
- obscure vision to them - perhaps for some reason mages need to be at least sort of seen. Maybe they need some line of sight. You can easily cut holes into whatever is blocking them but if there is need for anything more - you can hide them behind branches (either in bushes/forest or just get some and stack them in front) or put some smoke. This would not completely hide the mages but it would definitely make them a lot harder to see and thus discern what they are doing.
- obscure the acoustics - we've already established that battles are loud. But perhaps you need an extra layer of auditory protection. You can have drummers, or horn players, or whatever. This can double as setting the pace for the soldiers and relay commands but the noise pollution would make hearing the mages even harder than it already is.
If they are seen or heard...so what?
Left this for last but it's actually not at all the least. It's a question that really needs answering. So...what?
Commands for armies can already be "overheard"
You need to order your men. You do that in a way they can understand - usually by shouting the commands (well, actually having many people walk around and shout the commands). This is already similar to mages. The enemy can hear that and react. Yet it's not been a constant problem since...forever. Or not - apparently people have still won battles and wars despite this disadvantage. So, it doesn't seem like mages would change things drastically.
Just in case you think "oh but I bet people could be REALLY sneaky with those commands. For example, how would the enemy know a foreign language. Or, wait, coded commands!" let me disappoint you - you can't hide military commands very well. Not if the enemy can hear them at least. If you have a large enough army you need to be as clear as possible when giving commands. You don't want your soldiers to stop and think "Wait, what was Klaatu barada nikto again - are we to advance, or fall back?". Also, with large armies you are likely to have mercenaries and/or people who don't all speak the same language. For example, that was the case with the Romans and later Eastern Romans (Byzantines). They'd instruct their troops in standard phrases, so everybody, regardless of what language they speak, would understand. Trying to vary and obscure that can't work well.
Also, very importantly:
Deserters would betray military intelligence
Sure, even if you have some good way to deliver commands that the enemy can't understand...that won't be the case for very long. There are always deserters. The enemy can just bribe them or soldiers might just decide they don't like this war. Fiction might lead you to believe that these (ex-)soldiers would be tortured for information or something but it's really not how it worked. Most times your enemy would welcome your deserters with open arms and even reward them for merely leaving. Be that with gold, positions, or just place to live. Any extra information would be welcome and deserters already don't have much loyalty towards you, so why not spill the beans for some extra rewards?
At any rate, deserters have always been a problem in armies because they can betray secrets. Some things are more secret than others but "what do your commanders tell you when they want you to attack/defend/hold/etc would be the first thing they'd be asked. Well, assuming that was valuable information. I don't really know if it was or wasn't but, again, considering people have won wars despite having deserters, I'd hazard a guess that the military commands weren't instrumental. There is a lot more valuable information like army position, troops, strategies, etc.
Enemies can already see war machines
Catapults, ballistae, cannons, siege towers, etc. I could even extend it to archers and even cavalry and other troops in some cases. It's all military tools that can cause a lot of damage and you can see them. You can see where they go - where a catapult aims is not that much of a secret, even if the exact target can't be pinpointed (well, both by people aiming the catapult and people being shot with it). Same with cannons. And achers are really more of a spray and pray but you give them a general location which is not hard to guess still. Cavalry or heavy troops may need some time to arrive but you can see where they are going.
So...enemies can already see where you want to strike. Yet wars have still been won despite this "disadvantage". Here is the thing - a battle is more than just being nimble, avoiding blows, and stabbing people. Even if you have the greatest soldier (even soldiers) that are invulnerable and untiring...that's not going to win the battle by itself. You need strategy and just being to jump out of the way of an attack is absolutely not that.
You can trick the enemy
Let's assume for a moment that the enemy can see/hear your mages and understand that your mage is going to drop a fireball with enough forewarning to manoeuvre away. Well, they might have played right into your trap regardless. You can easily have your mages cast spells only to break up formations or force an army to take the route you want. You may want to push them towards your cavalry and slam into them from the side. Or you may want to open up the enemy lines enough to drive a wedge between them, destroy their formation and ultimately rout them. Or you can manipulate them in any other way just using the threat of a spell dropping and making the enemy play by your rules.
And this is how Hannibal, widely considered to be one of (of not the) the greatest military commander in history, beat the Romans so badly so many times. He always forced them to fight on his terms. Strategy wins wars. It's a harsh lesson the early Romans bitterly learned. Hannibal was the greatest enemy they had ever faced and taught them how to fight.
So...let the enemy see your mages. What are they going to do - stand and take the fireball to the face or move and take your carefully planned attack to the face? In either cases you win.
Chaos in battle
I left this point for last. I wasn't sure where to include it but it could (it should) eye opening. This is a short excerpt of Game of Thrones (Season 2, Episode 5). The characters here talk about wildfire. In-universe this is a highly flammable substance - very heavily inspired from Greek fire. You can think of it as "napalm" for all intents and purposes - very flammable, very easy to deploy and cause devastation.
I'm linking the full clip from the beginning for a little bit more context but the important bit of dialogue spans from 0:52 to 1:45:
Here is a transcript of (omitting more irrelevant lines):
HAYLENE: [...] [Wildfire] is fire given form. And we have been perfecting it since the days of Maegor.
BRONN: To do what?
HAYLENE: The jars are put in catapults and flung at the enemy.
TYRION: How much do you have?
BRONN: If you could get real soldiers to man the catapults, then maybe you'd hit your target one time in ten, but all the real soldiers are in the Riverlands with your father.
BRONN: I don't know if you've ever seen a battle, old man, but things can get a bit messy. 'Cause when we're flinging things at Stannis, he's flinging them right back at us. Men die, men s*** themselves, men run, which means pots falling, which means fire inside the walls, which means the poor c***s trying to defend the city end up burning it down.
So, this is more of a reason why not to use Greek fire. Wildfire in the show/books. It's difficult to deploy, it's easy to go wrong, it's hard to even aim properly, it's messy, the chaos of battle is really overwhelming and can cause accidents. That's bad enough with normal soldiers and equipment - somebody might drop a sword, an arrow, a spear, whatever. But with G̶r̶e̶e̶k̶ ̶f̶i̶r̶e wildfire an accident can cost your life, the life of everybody around you, as well as the city you are trying to defend.
I'd also like to note that Greek fire has historically been almost exclusively used for defence. It's so dangerous and hard to deploy that it's madness to try and bring it with you when attacking. At the very least it gives the enemy a nice target to aim and possibly burn your entire army. Also, it's very easy for you to just do this by accident without the help of the enemy.
Even when defending, Greek fire couldn't always be used - it would need favourable circumstances to be deployed. It was used very effectively against ships but you need good enough wind - if it's against you then you're really just burning your own ship.
Anyway, back to wildfire. Here is why I think this is important magic is also dangerous. Or at least most depictions of it are. Do you really want your mage to flinch from an arrow or something and set your own troops on fire? Or disintegrate themselves? There is chaos in battle. I've mentioned it a few times but I really want to hammer this point down. Battles. Are. Chaotic. Mages might be a great boon but if there is even the slightest chance of something going wrong, then trust Murphy's law, it would go wrong. Maybe not this battle, maybe not the next one but eventually they'd summon a demon they shouldn't have, or create a thunderstorm that devastates your own ranks, or unleash a plague that affects the commanders, or simply explode or whatever.
A big enough failure could cost you the war, despite how many battles you've won. What happens if the mage takes out your entire army by accident? Or kills the king or general? Or does whatever to make you lose a very key battle.
It's entirely possible that mages are too powerful and problematic to use on the battle field.