From the Super Mario Wiki
Cannonballs are heavy metal spheres that are launched from cannons at high speeds. Mario and Luigi were able to stop the lethal shots by stomping them in mid-air; they could also be dodged relatively easily. They appear most prominently in Super Mario Bros. 3 where they are fired from cannons mounted on Bowser's tanks, boats, and airships.
Cannonballs occasionally appeared in several episodes of The Adventures of Super Mario Bros. 3.
In the game Mario is Missing!, Luigi had to return the cannonball of the Emperor's Cannon to the Kremlin. It had been stolen by Koopa Troopas.
Cannonballs are again used in Mario & Luigi: Superstar Saga, where they are fired at the Mario brothers by Gunner Guys in battle.
Cannonballs reappear in Super Mario Galaxy with a more technological appearance. These newer projectiles sport a white line around their center and two yellow circles on opposite sides. In this most recent appearance cannonballs are still fired from cannons, most of which are located in Battlerock Galaxy and Dreadnought Galaxy. One notable difference with these cannonballs is that rather than simply colliding with the hero they explode upon impact. This will hit Mario and knock him down; it may also result in him being thrown off a platform or into a Black Hole. Only Star Bits are useful against cannonballs. Sometimes, when a cannonball is blown up by a Star Bit, it will produce a coin, but sometimes they will blow up into nothing.
Cannonballs make another return in New Super Mario Bros. Wii, and they only appear in World 8's airship. The giant cannonballs also return from Super Mario Bros. 3. Since the cannons are always found in a group, there is a high chance for the player to earn endless 1-Ups by jumping on each cannonball consecutively without touching the ground.
Cannonballs also appear in the Wii U title, New Super Mario Bros. U, where they act just like the ones in the predecessors. They can only be found in The Mighty Cannonship, from Soda Jungle. There is also a Challenge, consisting of jumping on many Cannonballs without falling to make many 1-Ups; the challenge is called Airship 1-Up Rally.
- In Mario vs. Donkey Kong, Mario will not get struck by a cannonball if he makes contact with one during certain frames of the backflip animation.