That was in towns where the message of the Gospel was rejected by the people after it was preached, not before.
More specifically it was where they were not received and the people would not listen to them.
There are few places which are more hostile or unwelcoming to Christian evangelists than Islamic communities.
So once again.... my point is that the Bible DOES NOT teach that it is ALWAYS right to preach the Gospel, everywhere at all times.