From the Super Mario Wiki
Stretch Blocks are blocks composed of five segments which constantly extend and retract up and down or left and right. They first appear in Super Mario World, where they serve as a bridge in certain levels. Stretch Blocks also make an appearance in some World-e levels of Super Mario Advance 4: Super Mario Bros. 3 .
Stretch Blocks make another appearance in New Super Mario Bros. Wii, where they appear at the end of World 9-2. In this game, they are now orange, rather than yellow, unlike in Super Mario World. However, these blocks will move up or down as they extend and retract.
Stretch Blocks make their latest appearance in New Super Mario Bros. U in Rock-Candy Mines as an integral part of navigating the world; they are color-coded red and blue, and will extend or retract depending on which colored switch is hit. They also appear in some levels with their New Super Mario Bros. Wii look. This time, however, they blink just before they stretch or retract.
Stretch Blocks appear in Super Smash Bros. for Wii U on the Mushroom Kingdom U stage. They have the same appearance as in New Super Mario Bros. Wii and New Super Mario Bros. U. Stretch Blocks appear in the Acorn Plains section of the stage.