Your heater does indeed work on waste heat from the engine. That’s why it takes a couple miles to get warm air in the winter.
The engine has what is called a water jacket surrounding the block. Water is circulated through it, and thus heated, by the water pump. That water is in turn cooled by running through the radiator.
When you turn on the heater, a valve is opened and that water is diverted through what is called a heater core. It is very similar to the radiator. The electric fan forces air across the heater core and into the passenger compartment. Temperature adjustments are made via the same valve. Opening the valve wider allows more hot water to flow through the heater core, thus increasing the temperature of the air exiting the core.
Some newer, and more expensive, cars will have auxiliary electric heaters. With these, you don’t get that warm-up time lag. You get heat instantly.
“The problem with the world is that everyone is a few drinks behind.” - Humphrey Bogart