Do you have or remember installing any kind of Tasker app, those that you can set things depending on where you are or if you connect to a Bluetooth device or wifi? If yes, first, go and force stop that app and I'd suggest to just uninstall it completely and then go to Recovery Menu and Wipe Cache partition.
If the above doesn't apply, have you turned on Smart Lock and have set any Bluetooth devices to activate it? If so, just remove all devices from Smart lock activations and I'd suggest to Clear all Credentials on Lock Screen and Security settings, plus turning off completely the Smart Lock feature (just to see if it's related) this in Trust Agents in Other Security settings.
If nothing above mentioned works and you have done a factory reset already, sorry but look for a replacement, it maybe a hardware problem. But before you do that, look online for the issue as I've read that some devices with Lollipop are showing similar symptoms.