Because while doctors operate on the heart, the heart must be stopped (i.e. stop it from beating) so the doctors can work on it. Hence without a pumping system for the duration of the surgery the patient will die. Therefore a machine is needed to do the work of the heart, which is what the heart-lung machine does, it pumps blood and reoxygenates it at the same time.