The engine can keep turning while the car is stopped because the clutch can interrupt the connection. See how that connection is rebuilt through friction.
In a conventional dry single-plate clutch, a friction disc sits between the engine's flywheel and the pressure plate. Clamping the disc transmits torque to the gearbox input shaft. Pressing the clutch pedal operates the release mechanism, reducing the clamp force so the engine and gearbox can turn independently.
What changes as the clutch engages
During engagement, the friction surfaces can briefly slip while transmitting torque and bringing their speeds together. If the load applied through the clutch overwhelms the torque the engine can sustain, engine speed falls and it can stall. Engine control, available torque and the clutch's engagement characteristics all affect that outcome.