It’s all a question of motives
In Matthew 6:1-6, Jesus shows that it is possible to do the right thing even with the wrong motives.
The point is that we do not act and believe because of expectations or threats, but because we are fascinated by God’s love and mercy (cf. 1 John 4:18-19).
There is extrinsic and intrinsic motivation. The question is: Do I want to do something, or do I HAVE to do something?
With an intrinsic desire, I am fascinated by something, I want to deepen something, have new experiences, create something. I do things without somebody needs to motivate me to do them. I also do them without being seen. For example: I talk to God because I want to spend time with him.
Jesus says: ‘Beware of practicing your righteousness before other people in order to be seen by them.’
Therefore, we don’t act in order to be loved, but we act because we have experienced God’s love. That is why the right does not need to know what the left is doing (6:3). We don’t have to count up.
More of sermon on the mount