AEDs work by analyzing the heart's electrical activity through electrodes placed on the patient's chest. If the device detects an abnormal rhythm, such as ventricular fibrillation or ventricular tachycardia, it will prompt the user to deliver a shock. The shock aims to reset the heart's rhythm, allowing the heart to resume its normal function.