Mass leakage at boundaries can be a critical issue for the reliability of the lattice Boltzmann (LB) method based on Cartesian grids. Despite numerous works based on the LB method, the intrinsic macroscopic mechanisms causing mass leakage are still not fully characterized but are essential to improve the mass conservation of LB simulations. In this paper, an original theoretical investigation of mass leakage at boundaries is proposed within the general LB framework. It is demonstrated that the mass leakage originates from the intrinsic deficiency of the wall-cut LB links at boundary nodes in recovering macroscopic momenta. From a mesoscopic-level definition, i.e., the net loss of distribution functions during the streaming process, the local mass leakage at individual boundary nodes, and its averaged value along smooth boundaries are mathematically expressed using macroscopic variables. The local mass leakage is shown to be dominated by terms proportional to the tangential momentum component. In contrast, the averaged mass leakage is shown to be contributed by various terms, including the boundary curvature, the tangential momentum, and the gradients of density, momentum, and momentum flux. Meanwhile, the amplitude of the averaged mass leakage is theoretically estimated to be proportional to the local grid spacing based on which a first-order accurate correction scheme is proposed. In addition, both the local and averaged mass leakage are demonstrated to be significantly dependent on boundary orientation with respect to the grid. The proposed theoretical analysis is assessed by performing numerical experiments. Two-dimensional weakly compressible flows through straight and curved moving channels are considered to estimate each term appearing in the theoretical analysis. The numerical results are in very good agreement with the proposed analysis, and the proposed mass correction scheme based on the averaged mass leakage effectively cures the mass leakage problems in the considered test cases.