From the Super Mario Wiki
Disappearing Boo Buddies are Boos found only in Super Mario World. They are only found in the Sunken Ghost Ship and cannot be defeated. They are randomly scattered throughout the screen and are completely motionless until they vanish and reappear elsewhere. The best way to deal with them is to move very slowly to avoid colliding into one. They are similar to the Boo Buddy Swarm found in the Donut Ghost House and Forest Ghost House, but Boo Buddy Swarms turn transparent rather than disappearing, and can move rather than staying still.