"Beware of practicing your piety before others in order to be seen by them; for then you have no reward from your Father in heaven. So whenever you give alms, do not sound a trumpet before you, as the hypocrites do in the synagogues and in the streets, so that they may be praised by others. Truly I tell you, they have received their reward. But when you give alms, do not let your left hand know what your right hand is doing, so that your alms may be done in secret; and your Father who sees in secret will reward you. "And whenever you pray, do not be like the hypocrites; for they love to stand and pray in the synagogues and at the street corners, so that they may be seen by others. Truly I tell you, they have received their reward. But whenever you pray, go into your room and shut the door and pray to your Father who is in secret; and your Father who sees in secret will reward you..."And whenever you fast, do not look dismal, like the hypocrites, for they disfigure their faces so as to show others that they are fasting. Truly I tell you, they have received their reward. But when you fast, put oil on your head and wash your face, so that your fasting may be seen not by others but by your Father who is in secret; and your Father who sees in secret will reward you."
God wants a deeply personal, interior relationship with each of us. A relationship of jealous, private love that is unknown to others. He wants us to live "a hidden life in Christ." The knowledge that we have such a God ought to fill us with joy for it seems to answer a deep yearning in the heart for profound, personal and intimate familiarity with our creator.
There are three areas of the spiritual life that belong to God in a particular way: almsgiving, prayer and fasting. With almsgiving we ought to be so secretive as to be largely unaware ourselves of when we give. With prayer we are beckoned by God to enter into a secret relationship with Him "who is in secret" because he wants our affections whole and entire, without possibility of distraction or interruption of a heart divided by seeking recognition of its act. With fasting Our Lord tells us to go so far as to actually go out of our way to ensure others do not know we're fasting by fooling them with a vigorous outward appearance.
To do anything so as to be seen by others is to build an altar to our ego. To seek praise by others for the satisfaction of self steals valuable space in our heart from He who is the heart's resident. Particularly in the areas of almsgiving, prayer and fasting.
Does this not conflict with "let your light shine before others?" No, that teaching applies to being a good person in general and not being shy about being a Christian and sharing, when asked, the reason for our hope.
For almsgiving, prayer and fasting we are rewarded. In the hereafter but also now, through interior peace and joy but especially through an ever deeper, personal relationship with the Father, a relationship with whom there can be no limit.