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 first time in the game at the end of the level when Mario has to free Luigi. It is found in an alcove behind a moving light. Mario must then use the mushroom to travel through two grates and 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 quicksand. There is a boo at the start who will see Mario and fall in love with him, chasing him until it gives up. Mario must also dodge the beams of several lights to avoid losing the Boo Mushroom.
Boo's Boneyard Galaxy
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.