Canada and Mexico are under no legal or international obligation to take in nationals not there own. We do the same thing. If Canada customs shows up at our port of entry with a Mexican national who just crossed the border from the US we will not take them back.
The funny part is that right now Canada is concerned that a large hoard of illegal aliens will head north as Trump takes office. They don't even have a Border Patrol.