Generally speaking, while in initiative order, creatures do not move when it is not their turn
Before I continue, I just want to make sure it doesn't go unstated that there are obvious exceptions:
- Using the Ready Action and choosing to move when using their Reaction, instead of taking an Action
- Being moved by an external force, like a spell or someone using the Shove Attack Action (possibly relevant!)
- Otherwise have a feature that causes them to move (maybe a boss monster's Legendary Action?)
- Possibly some other specific circumstance
But setting those exceptions aside, a creature should stay in place until its turn begins.
So if a creature is surprised (or enters combat normally!), it should generally not move anywhere until one of its turns comes up while not surprised. If a creature is moving when it gets surprised, then it stops moving until a non-surprised turn comes up for that creature.
This makes sense: Surprise is generally an abstraction for a group of creatures getting an extra chance to get some damage in before anyone on the receiving end has had a chance to react. It might seem weird for the cart to stand in place for what is nearly 6 whole seconds, but that is the nominal benefit that Surprise is supposed to confer.
Alternatively, there's ways to work around this if, as DM, you don't like this mechanic.
Alternative: The horse-drawn carriage
Any time I'm dealing with a vehicle that is, in Principle, autonomously driven—I would nominally consider a Horse-Drawn carriage to constitute as such—I usually just assign it an Initiative Order of 20 or 1, and have the vehicle (and anything/anyone on it) move X feet on that initiative count as a Lair Action for this encounter.
If you're unfamiliar with Lair Actions, I suggest looking at some of the Boss-tier monsters in the Monster Manual, who often have Lair Actions that occur at specific initiative counts, usually 20 or 1. For example, see the Ancient Black Dragon, on page 87 of the Monster Manual.
So in this case, I might cause the carriage to move forwards at its listed speed every time the Initiative count reaches 1. For the creatures that are Surprising the cart, this gives them a chance to
- Attack the wheels, slowing or stopping the carriage
- Attack the horses, injuring them or causing them to break free from control
- Climb onto the cart, so that it moves them with the cart
All of which give them a chance to take actions without artificially interrupting the movement of the cart.
The Dragon Rider
In this case, the dragon is usually considered the "Mount" of the creature who was riding it; its initiative would be the same as the rider, and occur right after it in the Initiative Order. The dragon would be frozen in place for the turn it is surprised, and remain there until its next, non-surprised turn comes up. You could apply the previous rule I suggested to the dragon, but given the dragon is (I'm assuming) a sapient creature, it's probably better to just apply the normal rules for Surprise.