They haven't
Like I already said, Apple didn't get to where they are today without being smart with their cash even on the minuscule stuff.
I've worked at Apple so yes I know what goes on in there. There was only 6 people on the team I worked with including me.
In the Xcode example, it's entirely possible Apple wanted XYZ feature that warranted new members to be added on the Xcode team. $300 x 10,000 DTK program members could mean $3million needs to be reallocated so perhaps Apple decided that XYZ wasn't important and ended up postponing it until next year's budget.
Fact is, we won't know what Apple did to make up the extra $3mil assuming there were 10k members or if they just ate the cost and also we don't know how this affects upcoming DTKs.
Sure, and that's why Apple invested in building DTKs and then destroying them later. Even before $500 credit, I don't think Apple was expecting to break even from that project. The low economics of scale for the production of hardware + software + delivery + recycling is a money losing project.
Extra $300 is unexpected added cost which could be in the millions.
Yeah, except let's break it down. There's a difference between cost and profit, and that's what we're talking about here.
First off, Apple invested in DTKs because it benefited Apple. They needed apps to work/be available on day one more than devs needed their app to work on M1 macs (a SLIM proportion of macs on the market) on day one. How different would the marketing have been if they said "hey, we'll have native apps in the future!".
Second, in terms of the credit. So you've said Apple is taking a $3m hit - let's break it down. Firstly here, devs paid $500 for the kit. They got a $500 credit. The only thing Apple is out here is the BOM for the DTK itself - which, as I explained above, is miniscule in their marketing budget (which is what it should really be considered).
Now, that $500 credit goes against a mac - the cheapest M1 mac is $699. So devs are still paying full price for a new Mac Mini, they just got to effectively borrow a glued together DTK for a few months for free. Let's look at that $699 mac mini. What's the realistic BOM on that device? Estimates have said that they're saving at least $120 just on the CPU alone. Beyond that, you've got a $30 hunk of aluminium, a $40 SSD (yep, it still ships with 256G), $30 of RAM, maybe a $40 PSU and not much else. The BOM pretty clearly is going to be less than half the retail cost, so in terms of profit, Apple makes no profit, but the developer has effectively covered the raw cost of those 2 systems. And that's before most developers splurge on premium upgrades (e.g. if a dev bumps the ram to 16G on their new one (+$200) - that alone would pretty much cover half the cost of the DTK unit.