Stars are won by beating your opponents. The more you score, the more stars you win! The thresholds do vary depending on the track. You can view the thresholds on the results screen after a race. Win more stars for more prizes!
Stars also count up for unlocking Countries in the Campaign, there's 3 Stars available in every Race, 10 Races and 30 Stars in every Country, 15 Countries and 450 Stars Total (350 to unlock every Country)!.