We have war when at least one of the parties to a conflict wants something more than it wants peace. ~Jeane J. Kirkpatrick
Because fiction thrives on conflict, and the biggest, baddest conflict anything has to offer is war, there's an awful lot of it in fiction. Historical fiction has subgenres for pretty much every major war and quite a few not so major ones - although "major" is something of a misnomer when it's happening to you.
Of course, historical and modern fiction have to content themselves with actual wars. We get to make them up.
Funnily enough, with all that wonderful material in history about weird ways wars have been started (okay, they were usually an excuse to go after someone) fantasy and science fiction seems to excel at the "traditional enemies who fight forever and have no idea what the actual war is about". Fantasy is worse than science fiction for this, despite there being all sorts of interesting reasons for two - or more - countries to be at war.
There's the basics - EasyBeats have to defend themselves against RagingAggressors or they cease to exist, BreedLikeRabbits need more space or they'll starve so they invade the neighbors, RuggedMountaineers (who seem to be related to the Horse People from Diana Wynne Jones Tough Guide to Fantasyland) raid SoftFlatlanders because those mountains don't let you grow shite.
Then there's the more sophisticated set - SnottyProtocolers offended by RoughButHonest and war gets going, no-one actually knows who owns that prime parcel of land but by deity it better be them, They (insert verb here) differently than We do so They must be evil.
I'm not going to rant here about unrealistic battle scenes - suffice to say that the reason streams get renamed things like Bloody Run is not because someone had the trots. A truly descriptive battle scene would have readers racing for the porcelain to expel their most recent meal at speed - and yes, that applies to modern war as well. I'm even going to be nice and not rant about authors who go on about what a wonderful leader SoAndSo is, then have him (and it usually is a him) do something that is so phenomenally dumb you wonder where the heck he left those wonderful brains that day.
Instead, here's a quickie sample of some of the better fantasy depictions of the logistics and strategy of war.
PTerry. Jingo (based on a historical incident. Really), Thud!, Small Gods (the amount of history stuffed into this book should have made it explode).
Tolkien's Lord of the Rings, more for the brief thumbnails of Sauron's preparations than anything else - it's bloody difficult to make war waged by existential evil work and Tolkein wasn't writing "fantasy" per se, he was writing "legends" which tend to skip all that detail stuff anyway.
Um. It would be so much easier to list bad examples, but I really don't want to do that. Over to you folks - which fantasy authors get their wars right?