Why Does My Laptop Only Work When Plugged In?
This almost always means the battery can no longer hold a meaningful charge, even though the charging circuit itself is still working fine — the laptop is effectively running directly off the charger with the battery no longer able to take over. It's a battery replacement in the vast majority of cases.
Why this happens
Laptop batteries degrade over time, and eventually reach a point where they can charge to a small percentage but can't actually sustain the laptop's power draw once unplugged, causing an immediate shutdown.
What to check first
Check the reported battery percentage when this happens — if it shows a reasonable charge but still shuts off instantly when unplugged, that confirms a battery fault rather than a charging problem.