Garlic is minced thinly in stir-fries to quickly release its flavor into the hot oil and other ingredients, while it's coarsely chopped in roasts to prevent burning during the longer cooking time and to provide a more subtle, infused flavor.
The size of garlic pieces significantly impacts the flavor and how it cooks. In a stir-fry, the cooking time is very short, often just a few minutes. Thinly minced garlic, or even garlic paste, provides maximum surface area for flavor release. When added to hot oil, the garlic's pungent compounds are quickly extracted, infusing the entire dish with its characteristic aroma and taste. If the garlic were coarsely chopped, it wouldn't have enough time to impart its flavor effectively during the brief cooking process.
Conversely, roasting involves much longer cooking times, often an hour or more. Finely minced garlic would burn and become bitter if exposed to the high heat for that duration. Coarsely chopped garlic, or even whole cloves, are better suited for roasting. The larger pieces release their flavor more slowly and gently, infusing the roast with a subtle garlic essence without burning. The garlic itself becomes soft and sweet, a delicious complement to the roasted meat or vegetables.
For stir-fries, add the minced garlic towards the end of the cooking process, after the other vegetables have started to soften. This prevents the garlic from burning and becoming bitter before it has a chance to flavor the dish.