It depends on the spell
According to the description of Eldritch Cannon's rule:
The cannon is a magical object.
Therefore, obey the rules for each spell as to how that spell interacts with the objects. That is, there is no general rule. Rather, it is a case-by-case basis as listed in the description of a spell.
Some spells say they affect objects. For example, Fireball:
The fire spreads through the corners. Light flammable objects in the area that are not being used or transported.
This does not require the object to make a saving throw. If it is flammable and does not hold, it just starts to burn. Then, the fact that your character is holding the Eldritch cannon prevents it from turning on.
Or take a chain ray:
You create a beam that arches towards a target of your choice that you can see within range. Then, three rays jump from that target to three other targets, each of which must be less than 30 feet from the first target. A target can be a creature or an object and can only be the target of one of the rays.
A target must make a saving shot of Dexterity.
The chain lightning is an "AdE" spell that requires the caster to select discrete targets and can specify that the cannon be included among the targets.
But, in all cases, a spell (or ability) must explicitly indicate whether / how it affects the objects. Holding the cannon does not impart any additional level of defense unless the spell indicates.