setting the environment variable is like saying "this is my deafult db". So if you don't specify a database, you will connect to whatever ORACLE_SID is set to.

Have a look at your TNSNAMES.ORA file and you will see TNS entries for your two databases, which is why my suggestion worked.