The most defining characteristic of a town in the Old West is isolation: towns were usually a dozen wooden buildings near a train station--a place where a traveler could stock up on supplies, get a drink, have a little fun, and move on. The buildings in the town are all predictable: the saloon, the brothel, the hotel, the general store, the jail, the train station, and the mission (church). Unless it is a mining town, the entire population survives on travelers, making the main character a stranger in almost every Western.
The Stranger, often a Man With No Name, comes into town alone. He (or sometimes she) is weary from travel and wishes to stay for a few days. This Stranger is sometimes an antagonist but is usually an antihero who, in exchange for the promise of either money or vengeance, will rid the town of its problems before moving on to the next town. The Stranger is a mystery, intentionally not revealing his past and never setting down roots.
Note that The Stranger is not the same as The Other. In literature, The Other is a trope that represents some sort of minority voice entering the world of dominant homogeneous society. Yet the West is not homogeneous; as the West consisted of native lands and Mexico before it was invaded by white settlers, the Old West is a very diverse place with Mexican settlers, native guides, Chinese laborers, free blacks escaping eastern racism, and even Europeans looking to escape their past. The West is a very diverse place, and while prejudice still exists, it is not as socially stratified as other societies.