Most likely your battery needs replacing as it's so degraded or you have a non-genuine battery installed that's not fully compatible with iPhone.
While the iPhone is on, go to settings > battery > battery health and see if it's displaying a percentage (__%). If it isn't, the battery is most likely non-genuine or something else has happened that I'm not allowed to say on this forum.
If the percentage is below 80%, then it's a good time to replace the battery because after that you can expect unexpected shutdowns due to low power.