Explain the importance of soil mechanics and foundation engineering in civil engineering. How do theoretical models of soil behavior contribute to the design and stability of foundations in various types of structures?