The DM and player can decide this together, and it'll differ based on the character of your game
Rules as written, there is no requirement to wait, or to be anywhere in particular, when the companion is granted. (This is true for abilities granted at levelling up in general, e.g. knowing new spells, or having an ability you didn't have yesterday.)
In more "gamey" campaigns it's fine to just handwave this and say "Poof! Now you have a camel!"
In a more story-based campaign, think through how you want this to add to the story. Since it's supposed to be "free" for the character I wouldn't make it onerous, but (especially if the player is amenable) it's fine to make it interesting.
- Perhaps you spend a night meditating and fast in the woods, and it comes to you?
- Perhaps you go out, track it down, and tame it?
- Perhaps the animal was sent by your deity, and meets you at some reasonable location?
In a campaign with a high level of realism, I'd talk with the player about is/n't possible. For example, at this level you might rule that certain kinds of companions that are normally allowed aren't realistic to find nearby in your biome.
Technically, you have to use your action to tell your companion to do anything except move. From the PHB, page 93:
On your turn, you can verbally command the beast where to move (no action required by you). You can use your action to verbally command it to take the Attack, Dash, Disengage, Dodge, or Help action.
It says nothing about the animal companion continuing to perform the action you made it do in subsequent rounds. If you want it to keep attacking, you have to keep giving it orders. Effectively, it acts as a surrogate for you in combat. Note that, as pointed out in this answer, the Animal Companion isn't substantially weaker than the Ranger himself, and might actually be stronger, particularly at low levels.
I've seen the houserule that the Animal Companion should continue to attack an enemy once ordered to attack them once suggested quite frequently, and the DM is of course free to decide that this is the case. But this is still a houserule, not RAW.
As for "why wouldn't they just get a guard dog that would do just that after a few months of training", there is currently no explicit option that allows you to do this. You can buy beasts (including a mastiff) that are trained as mounts, but buying/training a dog to attack your enemies (which may include dragons, elementals, ghosts...) is entirely up to the DM. Even if they allow it, such a dog wouldn't get the bonuses that the Animal Companion gets and would therefore be weak at low levels and very quickly become effectively useless.
Best Answer
Yes, per RAW a ranger can have pteranodon as his/her animal companion.
The two prerequisites for a ranger's animal companion are (PHB page 93):
A pteranodon satisfies both of those requirements.
Also relevant to address the AL part of your question is this quote from the AL FAQ v8.2 on page 6:
Per this reference, you may certainly use the Monster Manual as a legal resource and the pteranodon from it as your companion. It would also appear that there are no class requirements imposed by the ranger's Beast Companion ability that you must meet to select it.