Behind this behavior is a precise power management system, which aims to protect the phone and ensure its safe operation until the last moments of charging.
The phone may suddenly turn off, despite showing a charge rate of 5% or more, but this does not necessarily mean there is a malfunction, but rather it may be a preventive measure to protect the device and user data.
Smartphones do not rely only on the apparent percentage, but also monitor the level of voltage and actual energy remaining inside the battery, to decide to shut down the operation before a complete discharge occurs, which may lead to technical problems.
The reason is that a sharp drop in power may cause the processor to stop suddenly; This may cause loss of unsaved data or errors in applications.
So the phone reserves a small portion of reserve power that allows it to close processes in an orderly manner, save open files, and then safely shut down the device instead of suddenly turning off. (Erm News)