My assumption is that the remotes transmit the code for the desired key plus a unique remote code.
Remotes are passive and do not pair with devices.
Devices can be made to respond to only one remote and it's unique remote code by pairing.
Unpaired devices/computers respond to any remote irrespective of whether it's paired to something else or not.
For the imac as Vazandrew says you can disable the IR Receiver or pair it with a unique remote if you need to remote control it.
To have both AppleTV's separately controllable by IR you ideally need two remotes and to pair each AppleTV with it's own remote causing them to ignore other remotes.
If you have an iPhone/iPad or iPod Touch Apple's free Remote app will do a good job of controlling the AppleTVs but in practice i find remotes easier to use providing they're not lost down the sofa sides!
Can the appletv remote code be changed so the remote does not operate other apple devices in the same area, like a near by iMac or second appletv unit?
Direct answer - no the remotes codes cannot be altered - computers/devices can be set to respond to a particular code only by pairing: