Check in System Preferences > iCloud
to see if they're both signed into the same iCloud account and both have Back to My Mac enabled. If you do, then you could have been connecting that way, rather than a direct LAN connection.
Note that if you have more than one user account on either Mac, you'll have to log into each user account to check this, as different users can be logged into different iCloud accounts.