The Mount size determines space control
Page 191 of the PHB specifies:
Each creature takes up a different amount of space. The Size Categories table shows how much space a creature of a particular size controls in combat.[table of size categories follows]
This gives us a baseline for how much space a particular creature takes.
Mounted rules from PHB page 198 also state:
A willing creature that is at least one size larger than you and that has an appropriate anatomy can serve as a mount...
This shows that there is usually a progression in space control as you move up in sizes. The only outlier is Small->Medium where both sizes control the same space.
Finally, it is suggested that Opportunity Attacks when mounted are generated from the area controlled by the Mount (PHB, 198):
If the mount provokes an opportunity attack while you're on it, the attacker can target you or the mount.
This strongly points toward the idea that the creature's space is the total space.
A medium creature mounted on a large controls a 10'x10' space and can squeeze through a 5' wide opening.
The squeezing rules from PHB, pp192) state:
A creature can squeeze through a space that is large enough for a creature one size smaller than it. Thus, a Large creature can squeeze through a passage that's only 5 feet wide.
Using this, we know that Medium creatures (who control a 5'x5' space) must mount Large creatures (that control a 10'x10' space).
While there isn't a specific rule about combining creature sizes, the OA recommendation suggests that the space controlled by the mounted and rider is determined by the space controlled by the size of the mount (which is the larger creature.) Otherwise, the OA would be additive and include both the spaces controlled.
The Large mount and Medium rider therefore can squeeze through a 5' wide space.
However, this ruling is not particularly strong depending on your analysis of Mounted Opportunity Attacks and Reach. But when imagining how a mount and rider work together, then it makes more sense.
Theatre of the Mind
Another way of looking at this is through your imagination. Consider a humanoid riding a horse and trying to go through a smaller space. The humanoid would against the back/neck of the horse and streamline as much as possible. The humanoid really doesn't contribute much to the overall space when doing that.