From the Super Mario Wiki
An ON/OFF Switch is an object found in Super Mario World and its remakes. It is stationary and can be used by Mario or Luigi either to change the path that a line-guided platform is traveling on or, in 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 Cape 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.
Names in other languages