Apparently this sort of thing happens. One of my parish priests had a protestant confess to him. He identified himself at the outset that he was not Catholic but that he had to tell someone. Father said he would be glad to counsel hi, but the “penitent” said he had rather all between him and father and God, and let God make the judgment. But they had a long time together, and Father said it was one of the most heartfelt experiences he ever had in the confessional, and he felt bound never to reveal any details. Said he prayed for him at every mass for a long time and shared the experience with his own confessor. He said it made him realize that his own confessions had become perfunctory.
"The World's Cathedral" from the book The Marble Faun by Nathaniel Hawthorne.
More than likely, hearing confession can become rote until one day, someone jolts you out of the reverie with a situation such as that.