Not to sure about your i) logic and your ii) theology.
i) Principles are not something you always follow to the letter without intelligent discernment.
ii) The biblical statements about the strangers living amongst you were made about people living legally amongst you who were not Jews.  It was not a blanket endorsement of anyone who wanted to to come into your country, in violation of your rules for entry.