There is a rabbinic prohibition against performing what is called Mekach u'Memkar (buying and selling) on Shabbat. Buying and selling, or performing transactions on Shabbat, is asur (forbidden). The rabbis did not want us to be involved in all kinds of business interactions during the course of Shabbat. Because of this, many poskim (halachic decisors) write that giving a gift on Shabbat would be asur because it goes from one person's property to another person's. The change of ownership is considered a transaction. However, there were other poskim who wanted to say that since nothing is coming the other way, since it's only one way, that would be permissible.
We tend to rule on the strict side in this case: a person should not give the gift unless they had already purchased it in advance and had already decided that it was going to go to this person. In that case, they had already performed the acquisition before Shabbat. We have a concept: I can do something beneficial for somebody else. I can conduct a transaction on another's behalf, even without his knowledge, if it's going to benefit him. So if, before Shabbat, I pick up the gift and say, “Okay, this is going to go to this person,” it already belongs to him in advance. Just handing it to him is already a formality.
This is especially the case when the item being given is for a mitzvah (commandment). If it's a piece of jewelry to wear on Shabbat to feel good, or if it's a sefer that the person is going to learn from, that's why many will give a sefer to him, and they already know ahead of time that they're going to give it to the person. Assuming they made that kinyan (acquisition) ahead of time, it's acceptable to give it. Otherwise, a person should refrain from giving gifts randomly on Shabbat because of the problem of buying and selling. Shabbat Shalom.

