In spite of the category, building the foundation is the most important part of building construction. Essentially the foundation carries and holds the load of the structure above it, and the load is not the structure alone as there could be additional loads like wind, rain, flood or earthquake.
The earth surface is not steady but dynamic. Plus the interior of the earth is turbulent with lava, molten metals, and hot water. Even the surface soil can be porous and can sink a bit; the foundation is supposed to take all these parameters. The walls of the buildings erected on old paddy fields can crack down as the earth below dries up in extreme hot temperature.
While designing the foundations, the total static and dynamic load needs to be calculated and in technical terms, the bending moment needs to be assured. There should be a factor of safety added to the calculation (This will depend on the soil strength and integrity).
It is common for people to add more floors than originally intended or sanctioned adding the load much more. The foundation in those circumstances will not be able to take up the load and would eventually collapse.
Even the tunnels constructed in the vicinity for underground railway can send shock waves to the foundations. For marshy land, the ideal foundation is pile foundation. Concrete foundation or slab foundations with or without basement could be the right solution. For that matter, Japan has developed a spherical Foundation (having the least surface area of contact) has found to be useful in earthquake-prone regions.
Many parameters need to be taken into account while designing the excellent foundation as the foundation design is not a child's play or a DIY project but a highly professional project. After all, we are concerned about the safety.