From the Super Mario Wiki
A Bob-omb Dispenser is an object found only in Super Mario Galaxy and Super Mario Galaxy 2. Bob-omb Dispensers are small square-shaped black plates built in the ground. The center of the plate is a raised semi-circular hatch that resembles the front of a Bob-omb.
When approached by Mario or Luigi, it will immediately dispense a Bob-omb, which, depending in what galaxy it is located, may or may not begin walking (though the latter is more common). Each Bob-omb Dispenser will only release one Bob-omb at a time, so it will only release another Bob-omb after the previous one has been destroyed. Bob-omb Dispensers usually appear in industrial-themed galaxies between the two games, such as the Battlerock Galaxy, the Dreadnought Galaxy, and the Space Storm Galaxy. In addition, Bob-omb Dispensers usually only appear directly next to, or at least very close to, cages or other obstacles that must be broken or moved for Mario to proceed through the level. Bob-omb Dispensers also play an integral role in the Bob-omb Blasting minigame featured in Super Mario Galaxy, where the player must destroy all trash piles within a time limit by throwing Bob-ombs.