Welcome to forum!
Usually it's because AI gunner can't see the target, this will be indicated by a red triangle instead of blue on the marked button here:
Make a screenshot when something strange happens, please. One of the causes could be a difference between visual and physical models, so you as a player could see people in trenches, but AI couldn't, and, vice versa, you couldn't see through some bushes, but AI can (but this case is more often than not is AI remembering he saw a target and estimating where it could be).