Clearly you are giving these questions a lot of thought.
Sadly, in many cases it is, indeed, illegal to help a person.
In our history, we can refer to the Quakers (Society of Friends.) The crime of treason can be described as giving aid or comfort to the enemy. Yet Quakers choose to adhere to Christ's teachings to "love your enemy." Consequently, both in England and later in the United States, Quakers were/are persecuted and prosecuted as traitors according to law. They argue that they must obey God rather than the "law of men," (and eventually won the right to be conscientious objectors.)
This pertains to your example of giving sanctuary to an illegal immigrant in one's house. Breaking the law in this way ~ as an individual ~ would be very risky. But many religious groups do exactly that ~ as faith organizations. ~ A Presbyterian or Methodist congregation may decide to give sanctuary to a mother threatened with being deported. A Catholic parish might shelter several families to protect them from being taken to ICE camps. Church World Services, Lutheran Refugee Services and other organizations might take even broader actions that would be extremely dangerous for private citizens to undertake on their own.
By acting as a congregation, denomination, or organization, people of faith can access resources to mount legal defenses against laws that contradict the teachings of Christ and would prevent them from exercising their faith.
Immigration is not the only issue that pits the mandates of faith against local, state, or federal law. Specific cities have passed legislation that makes it illegal to set up public food kitchens or distribute food to the homeless. Faith communities have opposed and defied these laws, going to jail when necessary, and arguing in court their right to practice deeds of charity.
I'm afraid I could go on and on! You might want to look up Sojourners (on Facebook or the publication) and Jim Wallis, also on Facebook. Also the actions and writings of Rev. William Barber II. For more scholarly study, look up the works of Dietrich Bonhoeffer, perhaps beginning with "Life Together."
Specifically on immigration, the book, "No More Deaths," by Sue Lefebvre, is available on Amazon.
Blessings of grace, strength, and discovery in your studies!
Religious freedom based on Matthew 25 would not criminalize leaving water in the desert for migrants, or try to prosecute those who feed the homeless. It would not prevent believers from providing hospitality to "strangers": immigrants, refugees, migrants, and whoever needs food, shelter, or protection. Actual religious freedom would not deny reproductive health care to all people of all beliefs based on the beliefs of one segment of one religion.
This is the passage referred to:
35 For I was hungry and you gave me something to eat, I was thirsty and you gave me something to drink, I was a stranger and you invited me in, 36 I needed clothes and you clothed me, I was sick and you looked after me, I was in prison and you came to visit me.’
37 “Then the righteous will answer him, ‘Lord, when did we see you hungry and feed you, or thirsty and give you something to drink? 38 When did we see you a stranger and invite you in, or needing clothes and clothe you? 39 When did we see you sick or in prison and go to visit you?’
40 “The King will reply, ‘Truly I tell you, whatever you did for one of the least of these brothers and sisters of mine, you did for me.’