I love old westerns and am curious as to how a town was laid out and built. It looked like there was one wide, main dirt road, with buildings on either side. The buildings seemed built up off of the dirt, but were they on piles, some kind of stone foundation, etc? Would the initial foundation have been different for the first stone buildings (courthouses, other govt buildings)? Those who farmed seemed to live out on their spread, but did people build homes in town too?
The West is enormous and includes many different types of environments, so the possibilities are diverse. If we consider the "West" that classic films and television attempted to capture, we can focus the answer to your question to what can be called the Inter-mountain Mining West. This was and continues to be one of the most urban places in the nation. Resources needed to support a reasonable existence tend to be clustered in isolated locations surrounded by vast amounts of land that is not easily made hospitable. Water is a leading factor, but towns also formed along transportation routes and where viable ore bodies existed (and so resources, including water, frequently had to be brought to the newly-formed urban center).
Communities tended to form along conventional lines - following patterns that people knew from where they lived before, but community planning wasn't necessarily a strong aspect of the West. Communities often took shape in a haphazard way, and it is not uncommon to find primary sources discussing the need to move an older structure that later residents had placed a street - forcing traffic to go around the older structure.
Wooden structures were often built without foundation - wood directly on soil. Sometimes a rock-rubble, primitive foundation provided some means to keep wood away from soil, but this would have represented a significant effort that was not always used. In archaeological excavations my agency funded - in a previous century! - we once found a shallow horseshoe-shaped trench cut into soil within a building. It appeared to us that this was for the erecting of a canvas structure with rocks placed onto of the canvas to keep it from easily being blown away. That would have been the first type of structures in a new town. This was followed by wooden buildings, and only when it seemed likely that the town was reasonably stable would anyone invest in masonry.
Wooden structures had the advantage of being easily moved, and in the Inter-mountain West it is not uncommon to find buildings were built in one community and moved to another within a few years of initial construction. These "migrations" of buildings can be extremely difficult to document because there is often little more than oral tradition that described these moves. I knew people who lived in homes in Las Vegas - houses that were clearly too old to have been built in that community - who maintained that their houses were originally build in Virginia City, hundreds of miles to the north. They were allegedly moved to Tonopah in the center of Nevada, and then eventually to Las Vegas. Proving that would be difficult, but there are instances of moving structures on a more modest scale that can be demonstrated to have occurred. The only existing International Hotel of Virginia City continues as a business in Austin, Nevada - nearly two hundred miles away. The two other incarnations of of the Hotel were burned in Virginia City (1875 and 1914).
Masonry structures required more substantial foundations because of the problem of weight bearing walls, but those foundations are not always regarded as adequate by modern standards, and restoration efforts designed to save historic masonry structures sometimes require reworking the foundation. This is certainly the case with historic wooden structures: banks often will not lend money to someone attempting to purchase a historic house unless it has a foundation that keeps wood from touching soil.
And finally, yes, of course, there were homes: since most Westerners were - and continue to be - urban residents, towns were filled with all sorts of places for them to live. This included everything from apartment buildings to individual houses.