From the Super Mario Wiki
“What do we have here...? Looks like a soft, white mushroom, eh? You know, the stuff you're finding is pretty weird... But I guess that's just the universe we live in, right?”
The Boo Mushroom is a type of Mushroom that appeared in Super Mario Galaxy and Super Mario Galaxy 2 and turns Mario into Boo Mario or Luigi into Boo Luigi. It's a white mushroom with a Boo-like face. When Mario or Luigi obtain this Mushroom, he will transform into Boo Mario or Boo Luigi. It is the least used power-up in Super Mario Galaxy, found only in the Ghostly Galaxy, Sand Spiral Galaxy, and the Boo's Boneyard Galaxy. It is used only once in Super Mario Galaxy 2, in the Boo Moon Galaxy.
The Boo Mushroom turns Mario into Boo Mario therefore giving him the power to do several things that ghosts do in the real world such as float through walls and fly. He can become intangible if the player shakes the Wii Remote and he can then go through the object. Another effect of being Boo Mario is that Mario will attract other Boos towards it and those Boos will make him lose the form by touching him. The only other way to become Mario from Boo Mario is to go into a light beam.
Super Mario Galaxy
In the mission "Luigi and the Haunted Mansion", the Boo Mushroom appears for the very first time in the whole game at the end of the level when Mario has to actually free Luigi. It is in a room behind a moving light which will make exiting the room without losing the mushroom an extra challenge for Mario. Mario must then use the mushroom to travel along until he gets another mushroom which he must use to actually free his brother Luigi.
Sand Spiral Galaxy
The Boo Mushroom reappears in the mission "Choosing a Favorite Snack" where Mario has the choice of either the Bee Mushroom or the Boo Mushroom. If Mario chooses the Boo Mushroom he will turn into Boo Mario and have to travel over a lot of quicksand. There is a boo at the start who will see Mario and fall in love with him, chasing him for several meters until it gives up. After that there are several lights all around trying to shine on him and make him lose his Boo Mushroom.
Boo's Boneyard Galaxy
In the mission "Racing the Spooky Speedster", Mario makes his final encounter with the Boo Mushroom when he must use it to race the Spooky Speedster and to win the level. There are many shortcuts that can only be accessed by Boo Mario and no lights to make Mario lose his Boo Mushroom in the whole level making it one of the easier levels.
Super Mario Galaxy 2
Boo Moon Galaxy
In the mission "Haunting the Howling Tower," Mario (or Luigi) must use the Boo Mushroom to go through walls and progress to the top of the tower.
Super Mario Galaxy Trading Card Description
When traveling through the Ghostly Galaxy, Mario needs some extra help to navigate this scary place filled with Boos and Bouldergeists. A Boo Mushroom is just what he needs. When Mario grabs this white mushroom, he transforms into Boo Mario and is able to float, and pass through solid walls for a short time.