From the Super Mario Wiki
Gravity Arrows are objects found in Super Mario Galaxy and Super Mario Galaxy 2. They can be found in several galaxies, including Battlerock Galaxy, Dreadnought Galaxy and Clockwork Ruins Galaxy. These arrows point in the current direction of gravity. When Mario uses his spin within their vicinity, the arrows will change direction and color, along with the direction of gravity.
Sometimes, by using other techniques, it is possible for Mario to progress without hitting a Gravity Arrow.