"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 others may praise them. 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 pray like the hypocrites; for they love to stand and pray in the synagogues and at the street corners, so that others may see them. 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." (Matthew 6:1-6) (NRSV)
Jesus focuses again on motivations. He uses two examples: almsgiving and prayer.
As I understand the matter, first century Jews regarded giving alms to the poor, whether directly or as part of synagogue worship, as an act of piety. It was the right thing to do. Jesus accepts both the practice and its purpose. His quarrel does not lie with the poor, or with those who use a well-established means to help them. Instead, Jesus takes issue with those who use the institution not to honor God or help others but to win applause for themselves.
In like fashion, Jesus does not have a problem with public prayers per se. He objects to those who use public prayers to win praise.
The hypocrisy, in both cases, lies in claiming to do something for the sake of others or in honor of God, while actually giving or praying in order to enhance one's reputation.
Far better, Jesus maintains, to give alms and pray in private. The poor will receive aid and God will be honored. The giver/prayer will be insulated from the temptation to do the right thing for the wrong reason.
I've known many who misuse the passage to discourage public prayer of any kind, providing relief to the poor, or being held accountable in any way for what they do by way of prayer or almsgiving. Such applications abuse the passage and miss Jesus' point--namely, that we are to seek to become selfless, utterly unselfconscious, in all things, including prayer and almsgiving. Insomuch as we do so, we become more nearly like God.