Wars are pretty commonplace in fantasy, for obvious reasons. They’re exciting, give a good reason to kill off lots of characters (creating danger, drama and tension) and are a perfect setting for heroism and the most vile villainy.
But how long should a war last?
There are several factors to consider. The difference in army size and skill (including any warmages present). The geography of the land (and whether navies matter). Whether any fantastical or geological factors are at play (volcanoes, firestorms, flying monkey attacks, etc). The competence of the rulers and generals involved. Is the technological advantage with besiegers or the besieged? And, last but not least, the nature of the constitution and peoples on either side.
History furnishes us with many examples. The Hundred Years’ War lasted quite a while. In fact, so long that the nature of warfare changed during its course. In the earlier period chevauchees (massive raids to seize booty and burn property) were commonplace, with the Black Prince carrying out many. The purpose was to show the French citizens that the French king was incapable of protecting them, and the cause was partly because it was hard to take a walled settlement by storm. Later on, the development of siege engines made it easier to conquer cities (during Henry V’s time). This also meant that the English policy changed, and instead of terrifying French peasants Henry V ordered that all civility and decency should be shown to them.
The Second Punic War would’ve had a different ending and been much briefer if the Romans had not been at the height of their pathological patriotism. When Hannibal’s victory at Cannae obliterated a Roman army four times the size of a normal full consular army, just about every other country in the world would’ve, quite reasonably, sought terms. The Romans, on the other hand, sold the land Hannibal’s army was camped upon for full market value and then carried on. [The Roman politico-military setup helped enormously as it enabled more armies to be raised despite the enormous loss of manpower]. In later centuries, Roman virtue was enervated by luxury, and they repeatedly surrendered to far weaker opponents.
In the opposite moral direction, in the same war, Carthage surrendered pretty quickly after Hannibal suffered his only defeat, at Zama. But decades later, during the Third Punic War, the city (whose territory was by then not an empire but Carthage alone) showed far more backbone and vigour when provoked by outrageous Roman demands into war. Yes, Rome won, but it took several years for a massive empire to subjugate a single city with very few resources.
Deus ex machina is generally frowned upon (and rightly so), but a real life equivalent happened around 1400. Ottoman forces were poised to conquer Byzantium, and would likely have succeeded, but Tamerlane (think Genghis Khan but a little later) and his massive army rolled into Anatolia, obliterated the whole Ottoman army and reduced the Sultan, quite literally, to a footstool [Tamerlane used him to stand on when mounting his horse]. Byzantium survived for another half century, due to this massive stroke of luck.
Brilliant generals can also play a significant role. Alexander the Great is the most obvious. He was personally heroic but also tactically and strategically astute. An underestimated advantage he enjoyed was that his father was probably just as good, and did all the hard work reforming the Macedonian army and transforming it into the most formidable military machine in the world. In addition, he enjoyed a significant number of highly talented subordinates, such as Craterus, Parmenio and Antipater. This allowed him greater flexibility, as he could comfortably leave Macedonia behind in safe hands (Antipater) and deploy forces under a competent general (Craterus) without worrying they’d either rebel or fail.
It’s also worth mentioning that battles are pretty rare in history (far more time is spent marching about). I do think this is an area where it’s legitimate to be a bit unrealistic on purpose when writing. Pre-gunpowder warfare often involved walking up to several hundred or thousand men and trying to stab them to death. Understandably, the men were not keen on this if it could be avoided, and leaders were wary of either outright defeat or losing so many men the victory proved Pyrrhic.
Not only that, but keeping a large army together required significant logistical foresight (if only for the food and water), and always ran the risk of disease breaking out.
Campaigns sometimes did happen over winter, but it’s more difficult to get food at that time of year, and to dig (fortifications, for example), so it often meant a pause in hostilities.
There’s also the difference between a war of conquest and a war of glory. Rome fought to permanently acquire new territory. In Ancient Greece, it was often the case that a single battle was fought and the victor would acquire beneficial terms from the loser, but neither city-state was at risk of extinction (as happened to Corinth when the Romans crushed them in the 2nd century BC). A war of conquest will be more bitter and hard fought, because people will fight the harder for their survival. If surrender is a viable option, it can weaken the resolve.
From a writing perspective, a war that lasts as long as The Hundred Years’ War would probably be the work of either a Silmarillion-like approach, or a mega-series (Wheel of Time, A Song of Ice and Fire etc). For a normal single volume or trilogy, a couple of years would seem a better prospect.