Well, the first 3 stars are awarded based on how well you do in a Career Event. It depends on the game mode. To get the 4th and 5th stars, you need to complete two specific goals for each event. You'll find these goals explained on the screen before the race starts.