Because you are letting the coolant that has been sitting in the heater core go through the entire system now, and it's cooler than the radiator coolant.
Coolant circulates from the engine to the radiator and back.
The engine heats the fluid, and the radiator cools it.
and it goes round...and round...and round...
get it?
Then, when you turn on the heater, it causes the fluid to also flow through the heater-core as part of the loop.
===
That's a simple explanation.
Are you looking for something specific?
It works because the heater core is a little radiator inside your dash panel. With another fan. Starting to overheat? Turn the heater on full hot and full fan and run the windows down - I've stopped overheating in vehicles by doing exactly that.
The principle is the same - just the direction that the heat takes is different (you don't feel the heat from the engine bay. You do feel the heat from turning the heater on.) That's it. The automotive heater is just using waste heat from the engine to heat the cabin anyhow.