This sounds like your power button is sticking or stuck and this is causing the factory reset process to start. This could be due to moisture or debris getting around the button. A recommendation I found on an old reddit post is to try lightly prying around the power button to see if you can release it from its stuck position. You could also try using canned air to blow around the button as well.