From the Super Mario Wiki
The ! Switch is a switch first seen in Super Mario World. The switches come in four colors, Yellow, Green, Blue and Red. Stomping or jumping on the switches activates them. When activated, they turn Dotted Line Blocks into ! Blocks of the corresponding color.
In Super Mario World 2: Yoshi's Island, Yoshi's Island: Super Mario Advance 3, Yoshi's Island DS and Yoshi's New Island, red ! Switches can be stomped on to transform Dotted Line Blocks into red ! Blocks. These allow the Yoshis to cross obstacles such as pits and spikes, or else reach an inaccessible area.
They have the same purpose in Super Mario 64 and Super Mario 64 DS; however, in Super Mario 64 DS, there is one switch, which activates every red ? Block, while, in the original, there are three which activate the red, blue, and green Exclamation Mark Blocks, depending on the color of the switch. There is no yellow ! Switch, since the yellow ! Block is available by default. The same ! Blocks are in the DS version.
They are later found in the Paper Mario series. This time, the switches only appear as red or blue. Blue switches can only be used once, normally for opening passages of some kind. Red switches can be used an unlimited amount of times, and are normally used for moving important objects. However, the red ! Switches found in the Palace of Shadow in Paper Mario: The Thousand-Year Door are the only red ! Switches that can only be used once. They move a wheel, allowing Mario and his friends to get to the Shadow Queen's throne room and crypt. There are also black and white ! Switches found in the Great Tree. Mario and company push the black switch to reveal four white ! Switches in the room where Mario found the blue key to free the other Punies. Mario has to hit the white ! Switches in this order: Sun, Moon, Puni and Star to retrieve the Super Boots. In Petal Meadows, Mario has to hit two blue ! Switches, called Tandem Switches, simultaneously to activate the Warp Pipe to Hooktail Castle. He accomplishes this by utilizing Koops's hold ability. These switches also exist in Super Paper Mario. The most common of these are blue ! Switches, which generally cause an event to occur. In Chapter 3-3, there are ! Switches that change color between blue and pink when hit; hitting the switch causes the platforms of the corresponding color to appear, while the other platforms disappear.
The ! Switch also appears in New Super Mario Bros. Wii. It can be accessed after the player beats World 3 given that will allow them to get the regular flag in course 3-4. After the switch is hit, all the invisible Dotted Line Blocks turn into Red Switch Blocks, which give access to World 3-4 goal. Hitting the ! Switch is required to beat World 3. There is also a second switch above the first one, which turns all ! Blocks back into dotted line blocks. Additionally, the ! Switches replace the Skull Switch in Bowser's final battle.
! Switches also appear in New Super Mario Bros. U where red and blue ! Switches are found in Rock-Candy Mines. Their function is to move the Stretch Blocks that are in the way to create a bridge and move to another area. However, these ! Switches have no "!" mark. As in the previous game, one can be found in the battle against Bowser, where its purpose is to enable the Ax and destroy the bridge, causing Bowser to fall.
The ! Switch appears several times in the SUper Mario-Kun manga. In one instance, the switch is used to defeat Rex. In another instance, a Reznor knocks Mario onto a building shaped like the ! Switch. After defeating the Reznor, Mario is shown exasperated at the invisible blocks, which require a ! Switch to activate.
In Mario Pinball Land, a Red ! Switch appears in each world. If Mario hits one of these switches hard enough, eight Red Coins pop out and land in almost every area in the world. Mario has to find the eight Red Coins around the world within the time limit. Hitting the switch is worth 3000 points. Mario can use the switch as many times as needed; once Mario gets all the Red Coins in time, he obtains a Power Star, and the deactivated switch is changed into a Red ! Block. In addition, there is one blue ! Switch during the final battle with Bowser. It can only be activated when at least one of the Thwomps in the room is raised as high as possible, which causes it to glow, and hitting it causes the Thwomp to drop to the floor, temporarily incapacitating Bowser.
In Super Mario Advance 4: Super Mario Bros. 3, small, yellow ! Switches appear in some E-Reader levels. These can be carried similarly to the P-Switches of Super Mario World, and when pressed, they turn the Dotted Line Blocks into ! Blocks for several seconds, similarly to in the Yoshi series. Unlike P-Switches, they can be pressed more than once and can even be carried while they are pressed. However, Mario is unable to use Triangle Blocks while carrying an ! Switch.
In the Game Boy Advance game Wario Land 4, there are different colored switches for different colored blocks. They will change from transparent to solid as Wario hits them from below. They are often found in Puzzle Rooms, where Wario can solve a puzzle to gain a Diamond.
Names in other languages