What is preventing my phone from staying locked?
Since you suspect this to be app related, install wakelock detector which should help you identify the wakelocks that are holding the screen awake. Read the Screen Wakelock section

Once the culprit is identified, Googling for that would lead you to the app, if the app name is not evident ( You may need to monitor over a few hours repeatedly, since the behaviour reported is not consistent)

Edit: Remember to monitor when the phone is not being used. Charging the phone to a fixed percentage like 90% before retiring for bed would be ideal monitoring time