From the Super Mario Wiki
The Barrel Cannon (also known as a Barrel Kannon or Blast Barrel) is an item found in the Donkey Kong series. It is a barrel which when entered shoots the character out, hence its name.
 Donkey Kong series
Barrel Cannons appear in all four Donkey Kong Country games. They can also be found by Donkey Kong in Donkey Kong 64. In these games, if a Kong goes into the barrel, it will do one of two things: it will either automatically blast the Kong to where it needs to go, or it will spin around and the Kong will have to press a button at the right time to blast to their destination.
They also appear in the game Donkey Kong Barrel Blast, along with new varieties of red and gold. In DK Jungle Climber, they are easier to aim with. In DK: King of Swing, they appear where the player has to jump into a cannon, as it turns left to right, and press the L or R button to burst into the air.
Barrel Cannons later appear in Donkey Kong Country Returns. They come in four varieties: a manual barrel cannon, an automatic barrel cannon, a manual skull barrel cannon, and an automatic skull barrel cannon. The skull barrel cannons destroy themselves when they fire the Kongs.
 Super Smash Bros. series
In Super Smash Bros., it appears in the Kongo Jungle stage, where it moves back and forth and occasionally rotates underneath the stage. If a character falls into the cannon, they can press the A button to fire themselves out of the cannon in the direction of the arrow. If they wait too long, they will be shot out anyway. Since the cannon sometimes rotates, this action can sometimes save players from falling, or it can launch them to their doom. Only one character may occupy the Barrel Cannon at any time.
In Super Smash Bros. Melee, it is an item. If a character enters it, the barrel will rotate, and the player can press A to shoot out of whatever direction it is in. The barrel is also found as a stage element in some levels (for example in the level "Kongo Jungle"), or can be found appearing randomly on a stage. The Barrel Cannon can be thrown at an opponent. When thrown, the barrel rolls until it touches a character or falls off the arena. If an opponent is captured, the Barrel Cannon will inevitably shoot the fighter in the direction the barrel is pointing. This item is quite heavy, meaning that only Donkey Kong can move around freely while holding it.
Viewing the Barrel Cannon trophy from the bottom reveals the message "2L84ME" (Too late for me), which is what might go through a character's mind if he or she becomes trapped in a Barrel Cannon. On a side note, Barrel Cannons disappear much faster than any other item if left alone.
In Super Smash Bros. Brawl, they are no longer a regular item. Instead, several Barrel Cannons can be found in several levels of the Subspace Emissary. Characters use these to get shot up higher or break bricks in their way.
 Mario series
In DK Mountain, which appears in Mario Kart: Double Dash!! and returns in Mario Kart Wii, there is a giant Barrel Cannon (referred to in the former as Donkey Cannon and in the latter as DK Cannon) that blasts competitors to the other side of the course. Another Barrel Cannon appears in the Maple Treeway course, where it serves the same function.
Barrel Cannons make a minor appearance in Mario Super Sluggers in adventure mode. When the player travels to DK Jungle, Donkey Kong meets him and says that there is a waterfall too far for him to jump across. Nearby, in a bush, is a barrel cannon which will launch the player across this waterfall.
Barrel Cannons are present in Mario Party 9. In DK's Jungle Ruins, if the player lands on a Lucky Space, they will be launched to a floating island to increase their Bananas counter. Many Barrel Cannons appear in the boss minigames Diddy's Banana Blast and DK's Banana Bonus, where the players use them to reach Bananas.
 Trophy Information