@riccardorusso start your phone is safe mode and see if that does it in that mode as well. If not then the issue can be a bad app. You will have start remove those until you find out which one caused this.
# To activate Safe Mode, hold the power key until the Power off icon appears.
# Press and hold the Power off icon until the Safe Mode prompt appears.
# Select Safe Mode to confirm.
If it continues to shutdown, it is possibly a power issue, so you need to consider checking the charging board for short circuits, missing or burned components etc. Also consider replacing the battery.
Since iFixit does not yet have a guide for that, use something like [https://www.youtube.com/watch?v=Rf7odVv9Co8|this video] to work on your phone.
IF nothing helps, I would also suggest that you backup all of your files on your phone to your computer and then do a factory reset. Remember, with that you will lose all of your saved files, password etc. Make sure you have proper backup on that.
Here is how to do a factory reset according [https://www.samsung.com/uk/support/mobile-devices/how-do-i-perform-factory-reset-on-my-mobile-device/|to Samsung]