Explain the significance of the finite element method (FEM) in mechanical engineering analysis. How does FEM assist engineers in predicting stress distribution, deformation, and thermal effects in complex structures?