When attacking you choose how many units will attack (those units that enter your enemy's area). These units (and ONLY these units) will go to the place you attacked.
The lying (routed) units "get up" at the beginning of the following turn.
Specifically, the routed units HAVE TO LEAVE the territory. They have to go to a neighboring empty territory, or a neighboring territory controlled by the player who lost.
If they don't have any empty/friendly territory to retreat to, or if doing so would cause the losing player to violate their supply limit - the units are destroyed.
If the routed units are attacked again during that turn, there is still a battle but they have no combat strength. If they lose again, they cannot retreat again - they are destroyed.