From the Super Mario Wiki
Number Balls are types of balls that can only be found in the Nintendo DS game, Yoshi's Island DS. They look very similar to billiard balls and have a one-digit number on them. These uncommon objects appear in levels such as Number Ball Special, Six-Face Sal's Fort and Find the Number Ball!
Like eggs, the player can pick them up just by touching them, although they are usually hidden throughout the levels. When they are collected, they can be thrown just like eggs to land in a certain slot. Once all of the Numbers Balls are in their correct slot, they can activate something, such as a door, to allow the player to progress. If the player is to throw the balls away from them, missing a slot, the balls eventually disappear and appear back in their respective locations.