A lookup sets a "value", not a "record"
When you use a lookup on the standard kintone screen, you select the record to copy on the screen. This is like telling kintone, "Copy the values you need from this record."
With plugins, custom JavaScript and the API, however, the instruction to kintone is different. What a program can tell kintone is not "copy from this record" but "I am putting this value in the lookup field, so find the matching record and copy its content."
In other words, a lookup operation in a customization should be thought of not as selecting a record but as entering a value that serves as a search key.