From the Super Mario Wiki
A Surprise Ball (also known as a ! Ball) is a spherical block that Baby Yoshis use during the events of Yoshi's Story. They are round in shape and float in mid air. To use it, the Yoshi must use his tongue on these objects, and they will be pulled in, and thrust upwards, ending up standing on top of it.