If I'm not mistaken, in the past I was told that there's a difference between them (obviously in the context of giving someone something for free), but I don't remember what it is.
In many cases they are synonyms, however a present is usually something that the giver has deliberately selected for the recipient. You can also call this a gift, but the word gift can be used for less selective things as well.
If I buy a box of chocolates and give it to my mother on her birthday, then that could equally well be called a present or a gift.
However, if a fast-food restaurant is giving away a toy in every child's meal, then that could be described as a "free gift with every purchase," but you would probably not call it a present from the restaurant, because the restaurant did not specifically select a personalized toy for each child.
The etymology of "gift" relates to something given to another person. This would be something freely given, regardless of the relationship between the two people, and not necessarily for any reason. Indeed, there may be no other specific person involved ("she has a gift to play the piano," "it was a gift from the company," etc.) In most cases of modern usage, "present" would be more appropriately expressed as "gift."
The etymology of the noun "present" in the context of "to give someone a present" relates to something presented to another person, such as an award or commendation. It is implied (and here's the fun part) that the presenter is present when the present is presented. ("It was a present from his father," "she received the present from her supervisor," etc.) The word is so much more complex than "gift" that it is little wonder over time the two have become colloquially synonymous.
Thanks to that colloquial usage, the difference between the words is subjective.
"Birthday gift" and "birthday present" are synonymous.
A wealthy individual or organization would give a "gift" to a charity (or a "donation" or even a "presentation"), but never a "present." In this very formal, business context, "present" is inappropriate.
As I think about this, I wonder if "present" can be considered a slang term, an informalization of "to present" or "presentation." It is, perhaps, because of this that you generally do not hear it used on formal occasions.
A gift can be (but does not have to be) something very grand, such as a $50million contribution to a university from an illustrious alumnus. A present is usually something more modest and personal, between two people.
A gift can be large or small, public or private.
A present is rarely grand, and is usually between two people and is a token of affection, often on a special occasion.
He gave his wife a gift|present on her birthday.
The alumnus gave the university a large gift.
The alumnus gave the university a large present. not idiomatic; the word "present" would be unusual there
The meanings of the nouns "present" and "gift" are very similar.
"Gift" has some abstract meanings that are not shared with "present":
GOAL! A gift for #LFC in the opening few minutes. @22mosalah keeps his cool and finishes for his 20th @premierleague goal of the season.
Spurs did not actually give Liverpool a present. They made a defensive error so the goal was very easy to score. You could not replace "gift" with "present" in this example.
When we give the gift of kindness, we're choosing to be the best version of ourselves.
Again in an abstract sense, use "gift".
On the other hand
The kids were downstairs and ready to open their presents before their parents were even out of bed.
In a very concrete sense of a box with a gift in it, use "present".
Present means something presented.
Gift is an ancient past participle of given, i.e. a thing given.
So, they are about as exact synonyms as you can get. If something is not handed over in person it could be argued that present is inappropriate, but it hardly matters. It could still be presented by someone other than the buyer, after all. This is most likely to apply to a "leaving present", such as from co-workers.
It does seem there are conventions, e.g. Christmas and Birthday presents; and we always use gifts to mean talents, but in that case it's partly because the equivalent presented things would be a bit of a mouthful, and partly because you don't receive those at a presentation, whereas seasonal gifts most people do receive in person (even if from the postman, there's usually an unwrapping :o)).
Yes, it's largely a matter of style.