Celebrim
Legend
While 5th-level Mages may be relatively common, and it would be fairly easy for such a mage to infiltrate a conventional castle using invisibility, fly, spider climb, etc. I'm not sure what the mage is going to do once he gets in. He'll have to devote most of his spell slots to defense/infiltration with relatively few left over for offense. Even if he can compensate for offense with items (a wand of fireball or lightning bolt might be good) his hit points won't let him stand and fight once he blows his invisibility by attacking. He might cause a lot of damage up front, but I don't think he'll last long.
Military tactics are often driven by economics. An armored mounted knight makes sense only if the cost of training, equiping and maintaing the knight in the field is less than the cost of training, equiping and maintaining an equivalent force with a different composition. If an armored knight is easily countered by a much less expensive unit, say peasant with a crossbow, then force composition will necessarily shift toward a larger force composed of less expensive units.
In D&D, the question has always been, does a force of low level wizards equipped in a relatively expensive fashion (scrolls, wands, etc.) have so much offensive punch, that it obseletes non-arcane soldiery as a main battle force. Under unmodified 3e RAW, and to a lesser extent under 1e, a pretty strong case can be made that it does. Since most DM's would not consider a world were army normally means 'a small force of flying invisible wizards with wands of fireballs' to be a desirable outcome, the question becomes what happens in your campaign world to prevent that outcome.
1) 'Wizards are really rare': One answer is that for every 5th level wizard there are 100 or so 5th level fighters, so the impact of Wizards is relatively small. The problem I see with this answer is that doesn't typically conform to player experience. Few DM's are so stingy with NPC spellcasters that there isn't a low level wizard or two in every community, to say nothing of what might be present in larger communities.
2) 'Wizards don't participate in politics': Another answer is that wizards just aren't willing to fight on behalf of the community, or our culturally forbidden to do so. This answer also has several problems, the first of which being that its an unstable situation. The first culture to break the rules gains a pretty significant advantage. Also, and even harder to get around, it again doesn't conform to player experience. The PC's not only encounter wizards as foes with political interests, the PC's themselves might be arcane spellcasters serving essentially as mercenaries in the employ of some political interest.
3) 'Something is wrong or missing in the RAW': This is my answer, mainly because it in part addresses the question of 'Are spell-casters just better than non-spellcasters?' that starts cropping up as PC level increases. The problem with this answer is obviously, 'Ok, but what is wrong or missing?'
Now, in 4e, this problem doesn't really come up, because 4e doesn't worry really about the simulation level effects of its rules, or really about the question of, "How do NPC's interact with other NPC's?" at all. And, that's another approach you can take.