When you toast spices, moisture cooks off and the spice takes on a warm, smoky, earthy flavor that can be totally different from the character of the raw spice. Raw coriander, for example, has a very citrusy aroma, but when toasted it becomes almost nutty.
Toast first, grind later. Raw ground spices are quick to burn, so always toast spices whole and then grind them. And only toast one kind of spice at a time: If you toast a mixture of whole spices, some will burn before the others are even close to being done.
How to toast whole spices: Heat a dry sauté pan over medium heat. When the pan is very warm, add the whole spice. Shake the pan to keep the spice moving and to control browning. After toasting, immediately remove the spice from the pan to stop the cooking. When cool, grind the spice and add it to your dish toward the end of cooking or right before serving. You can try this technique in Peppery Pink Lentil Soup.