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.)
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.