When trying to infuse spices into an oil, why is it important not to cook the spice? I read that one there are different ways to infuse a spice into oil including leaving in oil for an extended period of time or if you want quick resuls, low temp heating for about 2 hours.

In the case of the latter, the article said you should be careful not to cook the spice which I think means high temp.  What exactly happens to the spice during cooking that wouldn't happen during low temp infusio.  For example does it destroy the flavours, reduce compounds such as peperine etc?

When making a curry, I notice people just put all spices in and cook it, I guess this would mean infusion isn't happening in a typical curry?
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.