From the Super Mario Wiki
The Countdown Timer (originally just Timer) is a feature in Super Mario World 2: Yoshi's Island, Yoshi's Island: Super Mario Advance 3, Yoshi's Island DS, and Yoshi's New Island. This feature is first explained in the "Welcome To Yoshi's Island" level. If a Yoshi takes damage, Baby Mario (or any other baby in Yoshi's Island DS) flies away in a bubble and starts crying, and the countdown begins, indicating how long the star powers can protect them. The timer turns from white to red when it falls below ten (In Yoshi's Island DS, the timer turns yellow below 10 seconds, and red in the last 3 seconds.). If the Countdown Timer reaches zero, a few Toadies come and steal Baby Mario (or whichever baby is riding on the Yoshi's back in Yoshi's Island DS).
The countdown will stop when the Yoshi retrieves the baby, and the Countdown Timer will slowly restore to ten seconds. However, if the Yoshi recovers the baby while the Countdown Timer is above ten seconds, no increase is awarded. Stars add one more second to the timer, and Middle Rings add ten more seconds, up to a maximum of 30. If the player has reached the maximum, any extra Stars released from Winged Clouds and Tulips are replaced with coins. The Countdown Timer also plays a part in determining the score for completing a level, with a point awarded for each second left on the timer.
In Super Mario World 2: Yoshi's Island and Yoshi's Island: Super Mario Advance 3, in addition to collecting individual Stars to increase the timer, the Yoshis can use items called 10-Point Stars (which adds ten more seconds when used) and 20-Point Stars (which adds twenty more seconds when used).