How to keep grenadiers out of range of normal cannons?

Grenadiers sometimes at random walk in range of a cannon despite being able to easily outrange them. How do I prevent them from doing that?