Shallow water equations have important applications in civil engineering. For these balance models, a numerical scheme with a well-balanced property is useful for reducing numerical errors and hence for resolving small perturbations of steady state solutions. In the past two decades, some high-order well-balanced finite difference schemes have been developed for the shallow water equations on Cartesian grids. However, it is not clear whether the well-balanced property can be maintained on curvilinear grids, which are often used in practice for physical domains with curved boundaries. In this work, we consider a two-dimensional case to show that the weighted compact nonlinear scheme is well-balanced for the shallow water equations in a pre-balanced form provided that geometric conservation laws are satisfied. Theoretical analysis and several representative numerical tests are conducted to validate the proposed fifth-order scheme.