Because it simply doesn't use spells above the allowed level, even if they are available...
Hero - casts all spells
Veteran - up to level 4
Warrior - up to level 3
Recruit - up to level 2 (sometimes level 3)
...
*Each difficulty level has its own AI tactics...
*The AI hero may not have the necessary skills to learn this magic...
*BUG (or interesting fact): if you give all spells to an AI hero in the editor, it will use them regardless of its class... so I had a Barbarian summoning elementals, and a Warlock shouting a battle cry...