In this research work, a new method for solving forward and inverse dynamic problems of mechanical systems having an underactuated structure and subjected to holonomic and/or nonholonomic constraints is developed. The method devised in this paper is based on the combination of the Udwadia-Kalaba Equations with the Underactuation Equivalence Principle. First, an analytical method based on the Udwadia-Kalaba Equations is employed in the paper for handling dynamic and control problems of nonlinear nonholonomic mechanical systems in the same computational framework. Subsequently, the Underactuation Equivalence Principle is used for extending the capabilities of the Udwadia-Kalaba Equations from fully actuated mechanical systems to underactuated mechanical systems. The Underactuation Equivalence Principle represents an efficient method recently developed in the field of classical mechanics. The Underactuation Equivalence Principle is used in this paper for mathematically formalizing the underactuation property of a mechanical system considering a particular set of nonholonomic algebraic constraints defined at the acceleration level. On the other hand, in this study, the Udwadia-Kalaba Equations are analytically reformulated in a mathematical form suitable for treating inverse dynamic problems. By doing so, the Udwadia-Kalaba Equations are employed in conjunction with the Underactuation Equivalence Principle for developing a nonlinear control method based on an inverse dynamic approach. As shown in detail in this investigation, the proposed method can be used for analytically solving in an explicit manner the forward and inverse dynamic problems of several nonholonomic mechanical systems. In particular, the tracking control of the unicycle-like mobile robot is considered in this investigation as a benchmark example. Numerical experiments on the dynamic model of the unicycle-like mobile robot confirm the effectiveness of the nonlinear dynamic and control approaches developed in this work.