Mostly, you don't. You can build a cage in a dead in hallway and then a cage trap beside it, and lever operate the cage so the creature escapes and then gets caught in the other cage. I've done this to transfer valuable creatures into masterwork golden cages. My dining hall can't have a hydra sitting in a wooden box! It needs gem encrusted gold!
You can order a creature to be moved to another cage/pasture/pit, but there's some rules.
Tame animals always transfer fine.
Captured prisoners transfer fine, but will be attacked by any active military en route (including caravan guards).
Wild animals will always escape immediately, but can be moved to a directly adjacent tile (ie, build the cage right beside another cage).
Captured thieves and babysnatchers will always escape, same as wild animals. A goblin spearman is fine, but a goblin thief will escape.
If the hauler is interrupted, they will calm down and grab a tame animal to put it back. Most wild animals and prisoners will cause subsequent job cancels and ruin any attempt to recapture. Sometimes dwarves will manage to re-capture a thief that if fleeing to the map's edge, and then successfully drag them to the new cage, but this isn't reliable.