The only way I can see this happening is if the battery in the fob was dead, which wouldn't explain how you *got* there (since it wouldn't let you start the car).
Anytime the fob is in the car and the car hasn't been run since the doors closed the doors will unlock. Also, the button on the dash won't lock the doors if any of them are open. This whole thing confuses me!
When you get out, you hit the button on the dash? That would lock, then unlock the doors (since one, or more, of the doors would be open at that point). In addition, if the fob was in the car when you try to lock it (via another fob or the handle), it does the same thing. It will lock, then unlock (or in the case of the handle just honk to complain without locking). One of the only problems I have with this system is that you *can't* lock the fob in the car at all (which would be great when you take it to get serviced somewhere but you can't get back by the end of the day).