From the Super Mario Wiki
A flashing Shell (also described as a flashing kamikaze Koopa shell, flashing Koopa shell, or flashing Koopa Troopa shell) is a type of Koopa Shell found only in Super Mario World and its GBA remake, Super Mario World: Super Mario Advance 2. It is created when a yellow Koopa without a Shell climbs into an empty one of any color, including its own, after being ejected from it, thus creating a flashing Shell. After its transformation, the Shell attempts to hit Mario or Luigi by spinning around and dashing towards him. It becomes impossible to separate the Koopa from it.
Flashing shells first appear in Donut Plains 4. Jumping on a Shell causes the Mario Bros. to bounce upwards, but it does not damage it. They can be defeated only with a Yoshi, a Spin Jump, or a Super Star. If any Yoshi eats one, it obtains all three shell abilities (causing sand clouds, flying, and breathing fire), as long as the Shell stays in the Yoshi's mouth. It is possible to respawn the yellow Beach Koopa that climbed into the shell, possibly leading to it dodging its own shell.