Teleport all entities relative to themselves in 1.13
Solution 1:
You're close, but the at @e[type=minecart,distance=..30] as @e[type=minecart,distance=..30]
will execute at each minecart position, for each minecart. So each minecart is being teleported to each position in order (e.g: 8 minecarts would be 64 tp's total), all ending up at the last one.
Instead, you should use this:
execute as @e[type=minecart,distance=..30] at @s run tp @s ~ 64 ~
Which makes the minecarts all execute at themselves, to teleport themselves.