As you say, the last paragraph of the ranger's companion text mentions needing 8 hours to magically bond with another non-hostile beast if when the previous one dies. It is probably the same for the first time around.
As for how to get the beast I haven't found specific ruling, so it's probably up to the player to find a beast to his liking (any plausible method should work unless the DM requires anything specific), ensure its friendliness and then bond with it.
A survival or perception check to find one in the wilderness and a handle animal check to calm it should do the trick, and the ranger spell list includes some spells that could help, like "locate plans and animals", "animal friendship", "speak with animals" or "conjure animals".
The beast selection is limited by what kind of beasts exist in his environment, which is something the DM decides.
A beast master has one animal companion until 4th, then two animal companions until 7th, and then three animal companions until 10th. A 10th-level beastmaster has four animal companions.
This is not affected by how you enter the prestige class.
So, for your example of a 5th-level ranger (who has the animal companion of a 2nd-level druid), when he becomes a 1st-level beastmaster, he gains four effective levels in druid, so his (already-existing) animal companion becomes as strong as the animal companion of a 6th-level druid.
At the ranger/beastmaster’s 4th beastmaster level, this animal companion is now as strong as that of a 9th-level druid. He additionally gains a second animal companion, at his beastmaster level — 3 (read: 1st). In total he has one animal companion that is as strong as a 9th-level druid’s, and a second animal companion that is as strong as a 1st-level druid’s.
In the end, as a 5th-level ranger/10th-level beastmaster, he has four animal companions:
as strong as the animal companion of a 15th-level druid.
as strong as the animal companion of a 7th-level druid.
as strong as the animal companion of a 4th-level druid.
as strong as the animal companion of a 1st-level druid.
If the beastmaster were not a ranger, but rather a barbarian, he would be exactly the same except that his first animal companions would be as strong as the animal companion of a 13th-level druid, not 15th.
(As you might imagine, the actual usefulness of those low-level animal companions is seriously limited.)
Best Answer
Basically, your companion would act on your turn, much like conjurations and I believe summons. I briefly had one in my campaign and during his turn, the beastmaster would take move actions along with the companion (counting as a single move action) and he would activate powers that allowed the ranger and companion to attack as one (usually these were two attack rolls for the same power, but other powers were one roll for a load of damage or effects.)
As posted from the quoted section. Move actions can be done at the same time. You can give up your standard action to have the creature attack for you (unless using a power that allows both to attack), you can give up your interrupt action for the turn to allow your companion to Opportunity attack (useful if the companion is blocking an exit while you're elsewhere), and you can both go total defense even gaining what a bonus to the total defense bonus in what I like to call "The Buddy Cop bonus".
Hope that helps.
Edit: Forgot to mention, but the ranger rolls initiative on his own. The companion always acts on the beast master's initiative. Also, the question came up on what happens to the companion if the ranger is knocked out. The way we ran it is that the companion could still act on it's own, but it's restricted to the basic options as the Ranger is the one who trained it to do special moves in cooperation with him. I can't be sure that that's correct however, but I believe that "unconcious so it effectively poofs" is restricted to conjurations.