From the Super Mario Wiki
Reversible walls are special stage elements appearing in the Flip-Out Galaxy in Super Mario Galaxy 2. They are red and blue walls that push out of the main giant wall sections in the galaxy. When the player spins, the red reversible walls will push out of the main wall sections while the blue reversible walls retract back into the main wall sections, and vice versa. The player can use these walls as temporary platforms or wall-jump up them to access other areas of the level. Cosmic Clones are able to pass through reversible walls in order to follow the player's exact movements, just as they are able to pass through any other obstacle they encounter if necessary.
The same type of wall makes another appearance in Donkey Kong Country Returns and Donkey Kong Country Returns 3D in the Switcheroo level, where they extend out of the wall and retract back into the wall in the same way, except now, they are activated by switches on the walls instead of by spinning. In these games, they are used to allow the player(s) to cross large gaps or abysses, or to defeat certain enemies if the enemies are positioned in front of the wall sections.