In two ideologically split rulings that could affect millions, justices say the administration can deport some migrants and turn others away at the border.