From the Super Mario Wiki
Purple Switches are a type of ! Switch found in Super Mario 64 and Super Mario 64 DS, though they are colored red in the latter. They are 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.