Hi there Samir,
It sounds like your phone isn't charging to 100% and shuts off on its own automatically. This should be pretty easy to isolate to either hardware or software. I would start by quitting all the running apps on your phone:
Force an app to close in iOS
1. Press the Home button two times quickly. You'll see small previews of your recently used apps.
2. Swipe left to find the app you want to close.
3. Swipe up on the app's preview to close it.
When you have done that restart the device and test the issue again:
iOS: Turning off and on (restarting) and resetting
If the issue persists, backup your device to iTunes, then restore it as new and verify that it works.
How to erase your iOS device and then set it up as a new device or restore it from backups
If it does, then restore your backup to either verify it still works and the software just needed reinstalled, or isolate the issue to the backup file itself.
If after all that the issue still persists then your phone will need service:
iPhone Battery and Power - Apple Support
Thank you for using Apple Support Communities.
All the very best,
Sterling