The prohibition given in the two hadîth that you mentioned is directed to Muslims living in the land of the polytheists who fear that their faith will be compromised and that they will not be able to carry out the dictates of their religion. A Muslim who lives in such lands and does not have these problems may continue his residency among them.
We arrive at this position by correlating between the various textual evidences that pertain to the matter. Though some hadîth prohibit residing among the polytheists, other hadîth permit it. For example, the Prophet (peace be upon him) said the following to the commanders of his armies: “Then invite them to leave their lands and emigrate. Inform them that if they do so, they will have the same rights and duties as the emigrants. If the decline, then inform them that they will be like Muslim Bedouins. The same Law will apply to them that applies to other Muslims, but they will not share in the spoils of war.”
The great jurist, al-Shâfi`î, comments on this hadîth, saying: “They would not have been given the option to do something that was forbidden for them.”
The Prophet (peace be upon him) permitted a group of Meccan Muslims to reside in Mecca before its conquest, including al-`Abbâs b. `Abd al-Muttalib [as related by al-Hâkim] and Abû al-`As [as related by al-Hâkim and al-Bayhaqî]
The Prophet (peace be upon him) also said: “Whoever believes in Allah and His Messenger, establishes prayer, and fasts Ramadân, Allah will admit him into Paradise whether he goes forth to strive in the way of Allah or remains in the land of his birth..” If staying in the land of the unbelievers had been forbidden, the Prophet (peace be upon him) would not have given them a choice between staying or leaving.
And Allah knows best.