How to gather entities into sets?

I think that I understand your problem, and I think that this couod help you.

/execute as @e[tag=mechabody] at @s if score @s ID = #target ID as @e[tag=mecharightarm,sort=nearest,distance=..10] if score @s ID = #target ID run tp @s ~ ~ ~ ~ ~

With this command you are able to select a mecha via /scoreboard players set #target ID <targeted bot>.
Then you are able to execute the first command, only change the tp parameters, the coordinates are relative to the mecha's body.
Maybe you need to modify the distance selector a bit for your needings, but I think, that the arm would never be further than ten blocks feom the body.
You can use this command also for the other components of the robot. Just make sure that all parts of the robot get the same ID.
And, but I think this is clear, you need to add a scoreboard objective called ID first, with has to be a dummy scoreboard.
Hope that i hepled you.

Commander guy


This command will teleport any armor stand that is a right arm if the scoreboard objective ID has the same value as any armor stand specified in the first part of the command.

/execute at <target selector for the body of every mech that should move the right arm>
         as @e[type=minecraft:armor_stand,name=mecharightarm] 
         if score @s ID = @e[type=minecraft:armor_stand,name=mechabody,sort=nearest,limit=1] ID 
         run tp @s <Position relative to body>

This uses the body as a kind of root, you would target the mech by targeting the body armor stand. If two mechs have their body in the exact same position, then the command may get confused and move the arm of the wrong mech.