With enemy units in melee range, mages have a 50% chance to engage in melee and 50% chance to follow their script. In case they were scripted to cast a specific spell, they will still follow the script at the next possible chance.
i too have found frustration in my current game when my lich (Air3, AS3, D3 - evoc 6 researched) has chosen to engage in melee (with 20 - 40 fatigue) instead of using shockwave or some other close combat spell.