From the Super Mario Wiki, the Mario encyclopedia
In Button Barrel Blast, these barrels are used to cross large gaps, much like Barrel Cannons, but they usually aim off-track. As a result, Donkey Kong or Diddy Kong must usually use a corresponding button to change the direction of the Button Barrel. Each time the Kongs jump on a button, the Button Barrel turns slightly to the right or left. After orienting the Button Barrel in the desired direction, the active Kong can jump inside to blast in that direction.
In Bonus Levels, the Button Barrels move around the area both quickly and automatically. A button is used in conjunction with the Button Barrel, although it is now used to shoot Kong Tokens out from it. Each token rewards the Kongs with an extra life.