Why is there a US custom and border protection in Canadian Vancouver?
So US Bound passenger can arrive in the US as Domestic passengers. Not every airport has the volume/need for a US CBP check point. So the passengers are pre-cleared, so when the flight arrive the passengers can just depart, connect as US Domestic passengers. So by having the passengers clear in Canada the airlines can server many more US airport that otherwise would have to go to some other port of entry, then connect.