One should learn the proper case with each verb, but there are some general heuristics (which are, of course, not always true):
The accusative is used for the thing or person that the action is done to and the dative is used for the thing or person the action is done for.
So:
Ich habe ihm ein Keks gegeben.
The action of giving is operating on the cookie, so accusative, and he is the recipient or beneficent of the action.
Your example of introducing people is not very good because this action is usually symmetric. But if you want to analyse this particular sentence, note that vorstellen literally means "put in front of". So, you take the accusative for the person you put in front of someone else, and you take the dative for the person who is the recipient of the action.
So, if you say "Hi, Dan, this is Mia.", you have presented Mia to Dan, so Mia is accusative and Dan is dative.
For English speakers the heuristics are simple: If an object has no preposition in English, it corresponds to accusative in German.
Beyond that, any German learner should buy a German grammar book in their native language that lists the exception, which for an English speaker includes words like "help". (Usually words that admit both interpretations, the help is done to you, but also done for you.)