From the Super Mario Wiki
An ON/OFF Switch (alternatively with "switch" not capitalized), also known as an ON Block, ON/OFF Block, or simply Switch, is a stationary object that first appears in Super Mario World and its remakes.
Super Mario World / Super Mario World: Super Mario Advance 2
In Super Mario World, it can be used by Mario or Luigi either to change the path that a line-guided platform is traveling on or, in #4 Ludwig's Castle, to toggle the direction in which the falling ceiling is moving. The switches can be turned on or off either by jumping against them from below, whirling Caped Mario's cape next to them or throwing an object, like a Koopa Shell, at them. Since using the cape to activate a block can hit it multiple times in succession, toggling an ON/OFF Switch that way does not guarantee that it will end up in the state intended by the player.
New Super Mario Bros. 2
In New Super Mario Bros. 2, two ON/OFF Switches appear in World Flower-, where they switch the direction of certain Conveyor Belts. In this game, they bear a closer appearance to other switches in the game, and can only be hit from below. The first one appears close to the end of the level where it controls two Conveyor Belts leading to the third Star Coin, and the second one appears during the boss fight with Lemmy to control the Conveyor Belt used during the fight.
Super Mario Maker 2
In Super Mario Maker 2, they appear as a placeable course element. When hit by the player, they can transform red and blue Dotted-Line Blocks into outlines or vice versa. In this game, they have more saturated red and blue palettes rather than having magenta and slate palettes. They can also transform other objects such as tracks, Conveyor Belts, Spike Blocks, and Track Blocks. In the night Ghost House and Underwater themes, they make the radius of light around the player smaller when hit.
Super Mario Maker 2
Names in other languages