When transferring a piece of data from one hard drive to another, where is the intermittent data stored? How does the computer know which SATA cable to "go up" to the new hard drive? Where is the data stored while it is figuring out which cable it needs to use?
That's quite a broad question, but I'll try to sum it up short.
When you power on your computer, it scans all SATA ports for any connected devices. If any bootable hard drive is detected (actually any bootable device, it depends on BIOS/UEFI config), computer will boot OS from it. OS collects all info about connected devices when booting. So if it knows there is a hard drive, it also knows where it is. There's no drive locating step. There is an intermediate buffer though, all copied data is passing through RAM.
As @Bob pointed out in the comment, some drives can be hot-plugged, so detection doesn't happen only on boot, but also later. Still, the principle is correct: If system knows there is a drive, it also knows where to look for it.