My iPhone reboots every time I try to turn it on
My phone recently does this thing where I would turn it off and when I power it on the screen briefly flashes on before rebooting, showing the apple logo. I can still use the phone normally while it's on but as soon as I turn off my phone and try to power it back on with the lock button the rebooting issue happens. Its also weird how the phone can turn on normally when I connect a charger instead of pressing the lock button.
I'm guessing it could be a hardware issue but I haven't dropped the phone or exposed it to any water.
iPhone XS Max, iOS 15