From what I've seen, this happens when you enter your house with another NPC close to you.
It seems to happen if they are talking or about to talk to you.
They are not in your house beforehand, they walk in with you... to put it in an RP context.
I've tested this when the NPC is right outside about to make a comment, then I go in and they are standing there, they make another comment then leave.
I made sure because frankly, I was getting tired of being paranoid they were robbing me and I didn't want to keep checking every container every time it happened lol.