Hi Rettax,
We understand your phone keeps turning off. We're happy to help.
To start, we'd suggest providing more specific detail about what you're doing. You mentioned that the phone turns off when you put in a password. What kind of password are you putting in where? Are you trying to sign in to an Apple ID account in the Settings menu? Are you trying to sign in to an account in a 3rd party app you have installed on the device? Are you talking about a passcode (the 4 digit code you enter to unlock a device)?
When the device turns off does it automatically restart, or do you have to press the power button to start it back up?
Answers to questions like these will help give the community a better idea of what exactly you're doing and seeing, so members can provide more relevant responses.
In the meantime, here's some basic steps you can try for unexpected restarts that may help: If your iOS or iPadOS device restarts or displays the Apple logo or a spinning gear unexpectedly
We look forward to your reply. Cheers!