Hi,
@sebastian606, welcome to the forum!
I think there are several factors that lead people to choose between Santiago and Madrid, but I don’t think there are any obvious reasons why one place would be preferable to the other.
If it works best for you to get the test in Santiago, and then travel to Madrid for your flight home, no reason to change that plan. If cost is a factor, the tests in the Madrid airport are about half the cost of the tests in Santiago, where Antigen tests run around 50€ and PCR tests about €100. You can easily use email to set up an appointment in Santiago for a test on the day that works for you.
Again, I think you will find a huge variation among forum members.
In recent years, I have always bought a round trip ticket whose return trip was Santiago-Madrid-Chicago-home. Having it all on one ticket is the only way I would do that, because if they are separate tickets, and you miss your connection in Madrid, you will be out a LOT Of money.
But this year, everything seemed so uncertain and constantly changing, I decided to buy my international ticket in and out of Madrid and worry about the details later. I have tentatively scheduled to take the train from Santiago to Madrid rather than fly. That way, if I don’t arrive in Santiago for whatever reason, I only have to worry about getting to Madrid, rather than trying to rebook a ticket from Santiago. But that’s just my preference, others will have figured out different ways to deal with the uncertainty.
I see under your avatar that you are planning to walk in 2022, in which case nothing that I just said will be up to date or accurate when you are planning your travel.