For one, the computers have a higher BOM and price, so an increase in manufacturing costs takes a smaller share of the total profit. Plus they only make 5 million computers a quarter, compared to 41 million iPhones+iPads.
iDevices are released on an annual schedule, which means delays are extremely costly (especially if they are timed for the holidays). This requires a very tight supply chain. It isn't as big a deal if the iMac slips by a month.
Finally, the market for iDevices is extremely competitive compared to desktops. Execution matters way more for iDevices and a lot more money is on the line. It is easy to experiment with iMacs because there is much less pressure in that market segment.