When trying to infuse spices into an oil, why is it important not to cook the spice?
Cooking and infusing are different processes.

When cooking with a spice you want it to release flavor and aroma into the food you're cooking with it, and usually you also enhance the flavor of the spice by frying / roasting it.

For infusing you want to be more gentle so you don't add bitterness and don't destroy subtle flavors. You want to slowly release the flavors and aromas and preserve them into the oil.