A heart-lung machine temporarily performs the functions of the heart and lungs during surgeries by maintaining blood circulation and oxygenation while the heart is stopped. It is primarily used during procedures such as cardiac valve repair, heart defect repair, and transplants. The machine consists of components like pumps, oxygenators, and tubing, and is operated by a perfusionist to ensure the patient's safety and stability throughout the surgery.