The iMac must be picking up the TVs remote. In Security system preference (I think) you can disable the iMac remote, or "pair" the iMac with it's remote so it ignores other remotes.
Until you pair it, it doesn't know which remote is it's one so it obeys all remotes.