How do I run apple script on a particular instance of Firefox?
To test the example AppleScript code, I duplicated Firefox and renamed the copy as Firefox 2.
This was texted under macOS High Sierra, using different scenarios:

Both Firefox and Firefox 2 running, with Firefox started first.

Firefox being frontmost.
Firefox 2 being frontmost.


Both Firefox and Firefox 2 running, with Firefox 2 started first.

Firefox being frontmost.
Firefox 2 being frontmost.


Just Firefox 2 running.

In all tested scenarios the example AppleScript code preformed as wanted, Firefox being the one acted upon, not Firefox 2.
I believe the key here is using the fully qualified pathname, e.g. &quot;/Applications/Firefox.app&quot; verses just &quot;Firefox&quot;.
tell application &quot;/Applications/Firefox.app&quot; to activate
delay 1
tell application &quot;System Events&quot;
    keystroke &quot;n&quot; using {command down}
    delay 1
    keystroke &quot;l&quot; using {command down}
    keystroke &quot;a&quot; using {command down}
    key code 51
    keystroke &quot;https://google.com&quot;
    key code 36
end tell


Note: The use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.