From the Super Mario Wiki
Stretch Blocks are blocks composed of five segments which constantly extend 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 again serve the same purpose as they did in Super Mario World. However, these blocks will move up or down as they extend on both sides.
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 also appear inside some levels with the same appearance of New Super Mario Bros. Wii. 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.