How to get the Green Switch in Super Mario World: Super Mario Advance 2
Enter the second green pipe on the ceiling. In this room, enter the pipe at the far end to reach the normal exit. The secret exit is also in this room. Either toss the blue shell in this room up at the highest Turn Block to activate the vine, and then jump up the Turn Blocks and climb to the Key and Keyhole. The other way is to fly up using the cape or use Yoshi to eat the blue shell. The secret exit leads to the Green Switch Palace.
The Green Switch Palace is a small palace found on the west side of the Donut Plains, which is unlocked by finding the secret exit in Donut Plains 2 in Super Mario World. Unlike the Yellow Switch Palace, this palace has enemies. This level cannot be replayed after it has been completed.
The palace consists of two rooms, which the player has 200 seconds on the Timer to complete. The first room has two levels. While the player may just use the above platform and take the Warp Pipe to the second room, which has the green ! Switch, there is also the option to hit the P-Switch and to defeat the Koopa Troopas on the lower level with a Red Shell. When all Koopas are hit at once, the player gets an extra life.
The second room contains nothing except the Green ! Switch which can be activated by jumping on it.
When the Green Switch is hit, all green Dotted Line Blocks turn to ! Blocks of the same color, which contain Cape Feathers when hit. In later castles, a single green ! Block often appears before the boss door, giving Mario or Luigi one more power-up before facing a Koopaling. These blocks also help the player progress through the levels by filling in some gaps. The Green ! Blocks only appear in 20 levels after that.
All this information was found online via gamefaqs.com