This is a question I brought up with my group and although I have made a ruling, I'm hoping to get a more authoritative answer (Sage Advice perhaps?).
The rules for mounted combat don't seem to specify how targetting works with the Attack Action. I've summarized the mechanics from PHB 198 below, with the final rule italicized because it is the subject of this question:
A mount is:
- A willing creature
- At least one size larger
- has appropriate anatomy to ride
Mounted and Dismounted:
- If within 5 feet of a mount, mounting or dismounting takes half your movement speed
- If mount is moved against will or you are made prone, DC 10 Dexterity or become dismounted and prone within 5 feet of mount.
- If the mount becomes prone you become dismounted within 5 feet of the mount. You become prone as well unless you spend your reaction.
Actions and Movement:
- A controlled mount must be a trained or domesticated creature, and they match your initiative while mounted. You may move the mount using its speed, and may only have it Dash, Disengage, or Dodge when it acts. Controlled mounts may move and act on the turn they become mounted.
- Independent mounts must be intelligent creatures and act independently, retaining their initiative order, movement, and full ability to act (presumably actions, bonus actions, reactions, etc.)
- If a mount provokes an opportunity attack while mounted, the attacker can target the mount or rider.
The targetting rules of an Attack of Opportunity is specified, but can an Attack action also target the rider when only the mount is in range?
The Mounted Combatant Feat suggests that by default attacks may optionally target the mount, but leaves it unclear if the rider may be targetted whenever the mount may be targetted:
- "You can force an attack targetted at your mount to target you instead"