From the Super Mario Wiki
The Bonus Block is a special block that appears in Super Mario World. This block appears in certain levels in this game. If Mario or Luigi collects 30 coins in the level and they hit this block, a 1-Up Mushroom pops out as a token for reaching its goal. If they don't have at least 30 coins, the brothers only obtain a single coin. Some of the levels they can be found in are: Yoshi's Island 3, Butter Bridge 1 and Donut Plains 3.