One of my players has a Ranger with Horde Breaker and Extra Attack (gained at level 5).
How many attacks can he make if he is equipped with two swords in the presence of two enemies?
How many attacks can he make if he is equipped with a bow?
A dual wielding melee ranger may take up to 4 attacks, a ranged ranger or a ranger who is single wielding may take up to 3 attacks.
Horde breaker allows you to make an extra free attack when there is an enemy within 5' of an enemy you attack weather you are making a melee or ranged attack. Extra attack allows you to take an extra attack as part of your attack action. Dual wielding allows you to make an attack as a bonus action when you take the attack action. So there are two distinct situations:
So the correct answer to your question is 4 attacks.
The ranger would get four weapon attacks if and only if there is another target within 5 feet of the original target. Two would come about from his Extra-attack, the third from a bonus action attack from his second weapon, and the four if there is another target within 5 feet from his Horde breaker.
This applies to melee weapons only. Ranged weapons may have a maximum of three attack if you are using a ranged weapon WITHOUT the loading attribute. While you can dual wield hand crossbows you only can generate a max of two attacks; one from each crossbow as the loading attribute prevents the use of that crossbow for anything other than a single attack in a turn. So your horde breaker and Extra attack would go unused.
With a bow you can generate three attacks, two from your Extra attack, and one from your horde breaker.
From page 93 of the 5e PHB
Once on each of your turns when you make a weapon attack, you can make another attack with the same weapon against a different creature that is within 5 feet of the original target and within range of your weapon.
Ranger with Crossbow Expert ignores Loading.
Ranger with Horde Breaker can attack a target surrounded by 8 other enemies with a light crossbow, then in theory take 8 additional attacks for a total of 9 attacks with the Primary weapon.
Same Ranger dual wielding light crossbows could then take a second attack with the off-hand on the same primary target, and repeat the 8 additional attacks (assuming they're all alive). That would be a total of 18 attacks.
The formation below shows Primary enemy target surrounded by his 8 friends marked with an X. Each X is within 5 feet of P.
X X X
X P X
X X X
The answer would appear to be 18 attacks.
Alternate Human, Crossbow Master feat, Horde Breaker at 3rd level, dual wielding light crossbows.