The current study is important from two perspectives. Firstly, in this article, we suggest a novel analytical technique for creating the exact solutions to nonlinear partial differential equations (NLPDEs). In order to study the dynamical behaviors of various wave phenomena, we can construct the several exact solutions in the form of Jacobi elliptic solutions, hyperbolic solutions, trigonometric solutions, and exponential solutions by using this method. Secondly, we consider a more generalized form of the (2+1)‐dimensional Korteweg–de Vries (KdV) and modified Korteweg‐de Vries (mKdV) equations that plays an important role in describing the shallow water. We successfully extract several soliton solutions for the examined equation. By choosing the appropriate parameters, some graphs of the discovered solutions have been represented in the figures. Every obtained solution has been demonstrated to satisfy the corresponding equation. The findings demonstrate that the method can be applied to solve a number of nonlinear evolution equations. The new solutions and the paper's findings could improve our understanding of how the waves move through shallow water and open up new research avenues.