In the original game, the hero slides down the list after being moved into a town garrison and back. When a hero is moved into a garrison, they are removed from the list of external heroes. There can be -8 external heroes and 48 garrisoned heroes.
When a hero is moved back from the garrison, there is no way to know what their previous position was in the list, especially since other heroes may also enter/exit the garrisons between placing him in the garrison and moving him back. Therefore, when a hero is moved from the garrison back to the map, they are added to the list last.
I am not aware of any cases of a hero spontaneously moving in the list without being placed in a garrison.
Thank you for the answer. Oh my god, I didn't even think about the garrison; it really does disappear from the menu after that, which is why it slides down.
If this cannot be undone due to the game mechanics, then that's fine; at least now it's clear why this happens.