1. It knows because when you ID sync the user ID with the ID service it also includes the adobe marketing cloud id which is the same ID being used in Adobe Analytics.
2. You need to implement the ID service fire an ID sync with the CRM id you want to use, the integration code for the data source(s) you upload data to in AAM, and the authentication state of the user when you are doing the ID sync(typically when they authenticate).