What does Matthew 6:2 mean?
Jesus has shown that the Father in heaven gives rewards to His people for practicing righteousness in truly righteous ways (Matthew 5:3–12). He warned, though, that doing good deeds so that the world will admire you is unrighteous; there is no heavenly reward when we do the "right thing" for the "wrong reason." Selfish motivation poisons charity into serving spiritual pride. Rather, we ought to serve God out of a pure heart. Public acts of good are part of God's will (Matthew 5:16), but only when they bring glory to God. What Jesus condemns here is motivation—acting "in order to" gain worldly praise.Jesus uses the example of giving to the needy. He has in mind putting money in the alms box in the synagogue or giving to those in the street who were begging. Modern readers should note that Jesus says "when" you give to the needy, not "if." The expectation was that Jesus' disciples would prioritize caring for the needy, a concept carried through into the Christian church (James 1:27; Galatians 2:10).
It's unclear what is meant by the sounding of trumpets, though trumpets were used in some aspects of Jewish worship. Perhaps some givers had deliberately timed their giving with the trumpets in order to be "caught" giving to the needy and praised by others for their generosity. They may have made a spectacle of their lavish gifts, drawing attention to their donation.
That temporary, eternally meaningless praise is all the reward such givers will get. Since they care so much about the admiration of other people, God will let that stand as their prize.