If your laptop turns off immediately when you unplug it from a power source, it means your battery is not working. Most likely, your battery reached the end of its useful life and stopped holding a charge.
In rare cases, laptop batteries will simply stop working out of the blue. This can happen if there is a short in the internal components of the battery. While most batteries are pretty rugged, extreme heat or cold, contact with liquid, or a sharp jolt from bumping or dropping your laptop may damage the battery.
Another possibility is that the battery connector inside your laptop is damaged. This can happen for the same reasons the battery itself might get damaged. Additionally, a power surge could affect the components that connect to the battery.