I was curious about this too because on one hand the NASA uses aluminum foil to protect the satellites in space from the heat of the sun.
On the other hand you can put aluminum foil into your cake and make your cake bake faster.
So it seems like a contradiction.
But what it is is that aluminum foil is both a really good absorber of heat but also a very good Emitter of heat.
Its not that it reflects heat it actually absorbs it but it also emits it very well and its also cheap and its found in many places.
So the aluminum foil will absorb the heat but then it will quickly Emit it back out so in the universe the aluminum foil on the satellites are absorbing the suns heat but then it will Emit The heat into the universe and keep in the satellite cool
but when you use aluminum foil in your cake the heat has been absorbed into the aluminum foil and then it will let go of that heat into your cake so your cake can be thought of as the universe except this is a limited portion and so of course the heat warms up the cake .
In the universe of just dissipates.