Hmm. I can only assume that the button has got pressed in your pocket, as the 5 doesn't auto-lock when you walk away.
The only alternative is that you had it locked at first, then unlocked it, but didn't open any of the doors within a minute or so. Then it assumes it was unlocked in error and...