Instructions
Beat the castle stage in World 8 to unlock the first star. It does not matter if you use secret exits to reach this stage faster than normally possible. The star is only linked to beating the World 8 castle. World 9 is unlocked once you get this star, but the individual stages in it might not be unlocked. Each stage is unlocked by collecting every star coin in each other World.
Complete every stage in World 1 through World 8 to unlock the second star. The only reason you would not get this star when you beat the castle in World 8 is if you used a secret exit in one of the other stages to bypass sections of the game.
Collect all three star coins in every stage in World 1 through 8 to unlock the third star. All eight stages in World 9 are unlocked after you get all 207 star coins in these worlds.
Collect all 24 star coins in World 9 to unlock the fourth star. There are three star coins on each stage.
Use the secret exit in stages 1-3, 2-4, 2-6, World 3 ghost house, 3-5, World 4 tower, World 4 ghost house, World 5 ghost house, 6-4, 6-5, World 7 tower, World 7 ghost house and 8-2. The secret exits in 1-3, 2-6, World 3 ghost house, World 4 tower, World 5 ghost house and 6-5 lead to warp cannons that allow you to skip to the next world.
Use all of the warp cannons you found to unlock the fifth star. Even though you do not need them at this point, the requirements for the fifth star are to complete every level, find all the secret exits and use all of the warp cannons.
Go to the mushroom houses on the map to get items. The mushroom houses no longer disappear after being used, so you can get an infinite supply of items.