I've noticed this in several games across several different versions. The AI consistently uses spells against Ophidians, lightning attacks against Crow Demons, and fire attacks against fire elementals. The AI both ignores units that it could damage with those attacks in order to target the immune units and neglects to use other attacks that could damage the unit.
This problem is easily replicated by attacking a stack of air shrills with a young crow demon. The air shrills will spam static blast against the unit as it flies around and pokes them to death with a stick. However, this problem only exists in tactical combat; if one clicks auto-resolve either the air shrills suddenly remember that they have other attacks, or the auto-resolve algorithm ignores immunities.