Melody switches are found in many stages in the game, starting in Stage 2 of Green Grounds. Melody switches must be hit in the right order, starting with the one that is flashing. If a switch isn't hit in time or the switches are hit in the wrong order, the Kirbys will have to start over. If they are hit in the correct order, either a new path will open, a secret door will be revealed, or an item will be rewarded.
I've heard there's a medal in space near some of the melody switches. I'm afraid that you'll have to hit all those switches, no matter how difficult that may be in space...”