Two basic troubleshooting steps to perform (test after each attempt):
A) Try a "forced" restart of your device using these instructions: Force restart iPhone
B) If you can, check your battery status in Settings>Battery>Battery Health & Charging>Maximum capacity. If it is close to 83-80%, have it replaced as soon as possible, since it might have unpredictable behavior.
If the issue still persists, it might be a hardware internal component failure, and I suggest that you make an appointment (*) and have your device inspected at an Apple Store or AASP (Apple Authorized Service Provider) among this list:--> https://locate.apple.com/choose-country-region . After checking it out, they'll give you all the available options.
Regards
Giulio
(*) You can do it: