Sounds like a pathfinding bug. I don't really know that you can do much about it other than put up with it. Admittedly I've had nothing like this happen myself so I'm probably not best positioned as to give advice. If you're not on the latest patch, you could try updating, but I'm not sure whether it would be fixed by even doing that.