This question already has an answer here:
Once when I was having a hard time a guy said to me, "I'm sorry you're having a hard time, I'll pray for you," in a way that made it clear that he was glad I was having a hard time because it gave him the opportunity to pray for me and feel good about himself.
I am interested in this phenomenon but also the much more general (probably universal) phenomenon of human beings finding justification for things they want to do, often by lying to themselves about the utility of the behavior to other people.
The best single word I can think of for this is contrived, but it is not close to precise. Similarly, dissembling, insincere, and so on don't really cut it.
I also looked at this list of cognitive biases but was unable to find one that expressed this idea.
Is there a single word for this? If not, a short phrase?