I suspect there was a choice of which disk to select for the installation. But the "default" one would have been for the drive on the MacBook. I'll explain what I just did to "confirm" this.
I am entering this on my late 2012 Mac Mini, and the internal drive (actually SSD) on it is called "Macintosh SD". One of my external devices (actually a Samsung 850 Pro 512 gig SSD) has 3 partitions, with two of those partitions being named "Mac Mini Backup SSD" and "MacBook Air Backup SSD". They each contain SuperDuper!, bootable backups I did for each of my Macs back on Saturday (like I always do). Also, on both the Mac Mini and each of the SuperDuper! backups, I have a folder entitled "Upgrades", and a sub folder entitled "OS 10.13 Upgrades", and within those folders I have a copy of the "Install macOS High Sierra" file (you did remember to make a copy of that file after you downloaded it, and prior to connecting the iMac in Target Disk Mode, right?).
So, I connected that external SSD to one of the USB 3.0 ports on my Mac MIni, went to System Preferences (on the Mini), selected Startup Disk, selected the "Mac Mini Backup SSD" choice from there, and restarted my Mac Mini from that "Mac Mini Backup SSD" bootable backup. The machine then did that, and when I got to the backup's desktop, I navigated to the "OS 10.13 Upgrades" folder I mentioned above, and launched the "Install macOS High Sierra" file. (I should mention that on that desktop, I did see icons for "Mac Mini Backup SSD", "Macintosh SD", and "MacBook Air Backup SSD"). After the Welcome screen, and then the license acknowledgement screen, the next one showed the disk "Mac Mini Backup SSD" as the "top" one. But right under that was a "box" that said "Show All Disks". When I clicked on that, it then showed the three disks "Mac Mini Backup SSD", "MacBook Air Backup SSD", and "Macintosh SD". If I was doing a new installation, I would have chosen "Macintosh SD".
All of that would be similar for your 2 machines. The "initial" disk, where the file "Install macOS High Sierra" was (after you downloaded it (and hopefully made a copy)), would have been the name of the one on your MacBook. As long as you formatted the iMac's internal drive as MacOS Extended (Journaled, GUID Partition Map), then the "Show All Disks" box should have been there, and selecting that would have allowed you to choose the name of the iMac's internal drive (the name you gave it after Disk Utility Erased and Formatted it).
I suspect that if you just clicked Continue on that "disk" screen (ie, did not click on "Show All Disks"), then High Sierra is being installed onto the MacBook. As long as you made a copy of that "Install MacOS High Sierra" file on another location on your MacBook, you'll be able to replicate the process again to install High Sierra onto the iMac's internal drive.
In actuality, after the installation is complete, and assuming the restart is from the MacBook, once you get to its desktop, you should be able to double click on the iMac's drive and see if there is anything on it.