I don't think it's just one thing:
- The foil reflects radiant heat, meaning that the only remaining way to propogate heat is through conduction and convection.
- The foil is an impermeable barrier which helps to keep the moist air (created by boiling off the moisture in the surface of the bread) near the sandwich, which reduces the rate at which the bread dries out, and we need dry items for them to burn.
It's possible that retention of the moisture within the foil slows the heating of the enclosed system as there's less loss of thermal mass, but I doubt that's a significant factor in most situations.
You might be able to test which of the other two is the more significant factor by running a test with foil that's been perforated such that it's not a good barrier but would still be reflective, and see how that compares.