The stimulus which triggers the initiation of each heartbeat is an automatic, ad infinitum, process. It is generated within specialized cells, located inside the heart. They are called pacemaker cells, and in normal conditions they are located in the Sinus Node, in the right atrium, near the connection with the Superior Vena Cava.
This means that if there is an adequate blood flow in the coronary arteries (the arteries that provide blood to the heart), an undamaged heart will keep beating on its own.
So a person with a completely dead brain can continue to have normal heart function as long as it receives oxygenated blood. That is what mechanical ventilation provides.