Why does elephant prioritize buildings over units?

When attacking with war elephants they vill attack the farm ignoring the vills in working on them. I have to target units manually often coz they will ignore units in their vision . Is there some sort of intended prioritization that I’m not aware of or is it a bug?