When Jesus tells us not to make a public display of our praying or our good deeds, he is telling us avoid being hypocrites; but he gave us a more important reason for keeping our goodness secret.
He said that it is when doing good that only the Father can see, that we are fully rewarded. It is only the good that we do for him alone, that our good acts deepen our intimacy with him.
But, if we do not let others see the good that we do, how can we be the salt of the earth, and how can we let out light shine, (as Jesus instructed us to do in his Sermon on then Mount?)
In Shakespeare’s “Henry V” play, after the English defeate a superior French force at Agincourt, Henry forbade his men from taking any credit for the victory. He had them over and over sing the refrain: “Not to us, Lord; Lord not to us; but to the name, but to your name, give glory.” “Non nobis Domine, Domine non nobis; sed nomine, sed nomine, tuo da gloriam “
They drilled that into themselves until they came to see that of their selves all they could do poop.