1...We recommended (that) Mary buy a gift for the boss.
This sentence means that we think Mary should buy the boss a gift. (a gift to the boss from Mary)
2...We recommended Mary to buy a gift for the boss.
In this sentence several or many people together want to buy a gift for the boss. The gift will be from all of us, but we think Mary is the best person to choose (and buy) an appropriate gift. But all of us will pay for the gift, which is for the boss from all of us.
Do you understand your sentences now?