Is there any way to prevent a factory reset, like password protection? I would basically like to protect my phone from resetting if it gets stolen.
Not possible on any stock recoveries that I have seen. A custom recovery would be needed for something like this, although there would be nothing preventing someone from flashing a different Recovery that doesn't have password protection.
Honestly though, factory resetting your device is probably the best thing a thief can do, since this wipes your personal data (at least the portion that's stored on the phone's internal memory.)
"Device Protection" or "Factory Reset Protection" added in Android 5.1 can prevent your device from being usable by a thief even if they factory reset it. Essentially, it keeps the device locked after a factory reset until you enter the Google Account credentials that were on it before the factory reset, locking out the thief (unless they know your account password). See this article for more details.
Note that if your bootloader is unlocked, or if you have the "Enable OEM unlock" developer option checked in Settings, the thief may be able to flash a ROM and evade this protection. Note also that it does not preserve the Android Device Manager, so this is merely to deter/frustrate thieves and not to help you retrieve your device.
I believe it's possible to protect your phone from the hard reset in case it's stolen from you or something related to that.
I would recommend avast! Mobile Security for your mobile phone. It contains a lot of features including the "anti theft" provision. In case your phone is stolen, you can remotely control it using other phone numbers. You can also activate the hard reset protection on your phone and thieves won't be able to activate the hard reset or factory reset on your phone. You can also decide how your phone should behave after the SIM has been changed. For example, the app can close all access to the phone settings, hence closing all acts of trying the factory reset and the hard reset protection simply recovers all data if a hard reset is attempted.
It has worked for me, and I have recovered my Android phone twice now.
Apart from using the Anti-virus which might or might not work, I think you should try applications that can protect certain area of your Android while allowing access to some.I use applock to protect access to my messages and gallery, I think you could also use this application to lock access to settings that lead to factory reset.I think that's the only way for now.There are other applications too that can work much better if you do some research.