The Mounted Combat rules say...
A willing creature that is at least one size larger than you and that has an appropriate anatomy can serve as a mount, using the following rules..."
This requires that the mount be willing, but it does not say whether the rider has to be willing.
Some instances in which a rider might be unwilling could include:
*If the rider had been grappled and carried by a creature that otherwise met the definition of a mount
*If the rider began as willing but the mount was later charmed, polymorphed, frightened, or had some other change of condition such that the rider no longer wished to be a rider but had not yet had their turn and so could not dismount
*If the rider was incapacitated or rendered unconscious and so could no longer give their consent as a willing rider (but by DM's decision could physically remain on the mounted creature)
If the rider had been grappled and carried by a creature that otherwise met the definition of a mount
If the rider began as willing but the mount was later charmed, polymorphed, frightened, or had some other change of condition such that the rider no longer wished to be a rider but had not yet had their turn and so could not dismount
If the rider was incapacitated or rendered unconscious and so could no longer give their consent as a willing rider (but by DM's decision could physically remain on the mounted creature)
[Note for the first possibility: The grappling rules say...]
When you move, you can drag or carry the grappled creature with you [...]
[Note for the last possibility: the "Mounted Combatant" Feat explicitly requires that the rider not be incapacitated to use the feat, but the Mounted Combat rules do not]
In any of these cases, would the removal of the rider's willingness to be mounted mean that the rider would no longer be treated as being in mounted combat, even if they had not yet had the chance to dismount?
In particular, would an unwilling rider still suffer opportunity attacks if moved by the mount on the mount's turn?
The opportunity attacks rule says...
You can make an opportunity attack when a hostile creature that you can see moves out of your reach. [... But you] don't provoke an opportunity attack when you teleport or when someone or something moves you without using your movement, action, or reaction.
But the mounted combat rules say...
[...] if the mount provokes an opportunity attack while you’re on it, the attacker can target you or the mount.