When used in an attack, cannons move along the path and attack all structures. They do simple blunt damage and do not have an AoE effect. Enemy units are ignored with the exception of Mortars, Monks,and Necromancer's skeletons that are attacked by cannons as well. At the Castle Gate, cannons often ignore towers right next to the gate and fire on the gate instead.
Cannons are the most effective way to take down structures as they all have a weakness to blunt damage. Cannons often need some management from the hero to avoid being killed by a stray Pyromancer.
Cannons always fire at obstacles and traps in priority. After finishing them off, they move on to attack towers. Spikes are often used as a bait to attract cannons making it easy for pyromancers to damage cannons.
Defending cannons attack all enemy units including the hero. Their Elite Boost Storm Cannons is quite effective in defense.
Cannons never panic; neither because of fire nor because of a Werewolf's howl.