From the Super Mario Wiki
Purple Switches are a type of Exclamation Mark Switch found in Super Mario 64 and its remake. There is at least one found in a majority of the game's courses. Though their exact effect varies from course to course, the most common effects are either making a set of breakable platforms appear or making unnavigable terrain passable, such as turning a steep slope into a staircase. With very few exceptions, the effect of the Purple Switch is temporary. A ticking sound indicates that the switch is still in effect, which gets more rapid as the effect is about to expire.