Building a foundation is not really a do-it-yourself project in most cases. It requires excavation, sometimes several feet deep and a lot of concrete work. There are several types of foundations. A basement is one. Stem walls around the perimeter (and at spaces in between) is another. Concrete slabs are another; these can be built in a T shape with a vertical wall under the slab or "on grade" with a single thickness of concrete that is thicker at the outside edges. All concrete foundations require a secure footing, the most important element of foundation building.
Determine the "frost line" for your area. This is the point in the ground at which the soil never freezes. It will vary. In warmer locales, the ground never freezes. In colder areas, the frost line may be 3 or 4 or more feet deep. Dig footing trenches with the top of the footing below this line, to prevent the concrete from heaving and buckling as the ground freezes and thaws.
Decide on a foundation type. Foundations can be shallow or deep. Use a shallow foundation where the soil is stable and fairly level, with no severe slopes or drainage issues. Use a deep foundation in areas with poor soil stability, on hillsides, in flood zones or other locales where a shallower foundation might tilt or slip. Dig deep foundations to bedrock or reinforce with steel or some form of caisson or pier.
Design the foundation to fit the building conditions. Start any type of foundation by digging footings, at least 2 feet wide and as deep as the frost line; some foundations will require extra width, some up to 6 feet wide. Match the foundation to the size of the building. A one-story garage may get by with a foundation 8 inches wide and 8 inches tall; a two-story house will require at least 10-inch dimensions. Check local building codes for specific foundation sizes and construction for various structures.
Install reinforcing bars in footings and foundations. Place rebar horizontally and vertically in both; put footing rebar vertically to extend up into the foundation wall. Start the footings with a base layer of tightly compacted gravel. Use a mechanical vibrator when pouring concrete foundations to settle the concrete and eliminate any air pockets which might weaken it.