In both games, his power grants Mario or Luigi the power to Star Spin. He briefly appears above their heads a couple seconds after they perform a Star Spin. This indicates that they can now do another. He also pops out of their hat to perform a little dance whenever they return to the Comet Observatory or the Starship Mario with a Power Star.
Super Mario Galaxy
In Super Mario Galaxy, Luma was presumably discovered by Princess Peach, who held him during the attack on her castle. Luma chases Mario to the Gateway Galaxy after he was knocked off the castle by Kamek.
There, Luma wakes Mario (or Luigi, this is where "Super Luigi Galaxy" begins) up and turns into his Star Bunny form. He insists the hero to play with him, leading to two other Star Bunnies. They make Mario or Luigi play hide-and-seek with them. When all three are caught, a castle-like structure appears. On top of the structure is Rosalina. He tells Luma to travel with Mario (or Luigi), lending her power to them. This allows them to Star Spin.
In the ending, all of the Lumas, including Luma traveling with Mario or Luigi, fly towards the black hole, and turn into new galaxies. In the secret ending obtained by collecting 120 Power Stars, he is seen in the Gateway Galaxy near what is presumed to be the spaceship that Rosalina rode with her original apricot colored Luma.