About a decade ago, there was a storm of anti-tobacco commercials put on by The Truth campaign. The one I remember the most went something like this: "A tobacco company donated $60 million to charity, then spent $100 million telling people about it." The two stats shown side by side make it clear, they were more concerned with looking good than being good.
Jesus has a problem with religious people that do the same thing. In Matthew 6:1, he said:
"Don't practice your righteousness in front of other people in order to be seen by them."
Like earlier in the Sermon on the Mount, Jesus is just as concerned with our internal character and motivations as our external behavior. He gives three examples here- serving those in need, praying, and fasting. Note that his issue isn't so much about these acts being done in public, it is more about the motivation of why you do them.
If you want to love someone and help them, it should be because you love them. It should spring out of the core of who you are. It should not be so that you can impress others. It also shouldn't be so that you can be impressed with yourself. Jesus addressed that in verse 3 when he said, "Don't let your left hand know what your right hand is doing."
In almost parallel form, Marcus Aurelius said it like this:
"A man, when he has done a good act, does not call out for others to come and see, but he goes on to another act, as a vine goes on to produce again the grapes in season."
There is a real challenge for all of us to not 'act loving' as a cover for us trying to look important/impressive/loving to others or to feel important/impressive/good to ourselves. When we make it about ourselves we ruin the whole thing.
Whenever we help someone because of what we get out if it, we are using them as a commodity and not treating them as a companion. It prevents love and connection as it creates an 'us and them' mentality. Jesus calls such people 'hypocrites' because they are acting like they are generous but they are actually being very selfish.
I see this temptation in my career in ministry. People are often vulnerable and willing to share important parts of their life with me. The temptation is to seek out people in need of pastoral care because of what I get from them (feeling important, powerful, wise, etc.) rather than what I hope for them. (healing, redemption, wholeness.) I have to constantly check my motives. Regardless of your career or type, this temptation is out there for all of us in a variety of contexts.
Dallas Willard says it like this:
"The kind of people who have been so transformed by their daily walk with God that good deeds naturally flow from their character are precisely the kind of people whose left hand would not notice what their right hand is doing—as, for example, when driving one’s own car or speaking one’s native language. What they do they do naturally, often automatically, simply because of what they are pervasively and internally. These are people who do not have to invest a lot of reflection in doing good for others. Their deeds are “in secret” no matter who is watching, for they are absorbed in love of God and of those around them. They hardly notice their own deed, and rarely remember it."
If you seek to truly be a person of compassion, devotion, and humility, these actions of charity towards others will be a natural outpouring of who you are. Your character determines your behavior. Or as Jesus says it elsewhere, "You will be known by your fruit."