The explanation is very easy. The first one, who believed and confessed openly that Jesus Christ was his Lord and Savior, died saved. The second person did not, because he believed the lie that he could get to Heaven by his good deeds alone--in short, making himself his own Savior and his own God (idolatry) and thereby rejecting the free gift of salvation from God through Jesus Christ.
Sitting in a church doesn't make a person a Christian anymore than sitting in a garage makes him a car. There are people--and churches--who profess Christ, but do not possess Christ. They have ritual without righteousness. They want to feel good without making any effort to BE good. It is not that easy to follow Christ--it is almost, but not quite, beyond human capacity.
Still we--his disciples--do our best, because of who HE is and what HE has done, paying a debt we can never repay--which clears the way for an inward, lasting joy right here on earth and the anticipation of knowing we will live with him in paradise when we die.
Christ came to save sinners. He didn't come to spend his time with people who thought themselves already good enough (the Pharisees) and by telling the truth he insulted them and was crucified. He came for you and me. All we have to do, is accept the gift of salvation, invite him in our hearts, live for him and love one another as he loves us. He offers us a divine guarantee and we would be fools not to take him up on his offer.
I don't really consider myself a sinner.