It will only fire at a tank etc. if it has line of sight. Just place it behind a hedge, buildings or woods, where it can't fire on any enemy ground units, and, more importantly, they can't fire on it, even if it reveals it's position firing at planes.
So you decide how to use these units, purely as AA cover sitting behind the lines, or as multi-use ground support and AA. Their range and calibre can make them good support units, as long as you protect them from tanks and don't let infantry get close to them. But with so little AA available, I don't usually take that risk, and position them similarly to my artillery in safe positions. Not only from enemy fire, but also where recon shouldn't be able to spot them, so that you don't get artillery fire or planes constantly dropping bombs on them.