There are a total of 12 hidden stages in the game with 8 of them appearing on the world map automatically when you have collected ALL the Red Diamonds in a world. Listed below are the remaining 4 which will appear when you complete the corresponding task.
Unlock Stage 9-1: Complete the game without using any Continues.
Unlock Stage 9-2: Complete stage 9-1.
Unlock Stage 10: Collect ALL the Red Diamonds in a world to unlock stage 10 in each world.
Unlock Stage X-1: Use the warp block which is found directly above the starting position in stage 4-3 (use bubble gum to reach it).
Unlock Stage X-2: Go to the first checkpoint flower in stage 6-7 and then continue to the right until you find a Bazooka Bee. Then bounce off it's back to find the warp block to stage X-2.