Fish schools and bird flocks exhibit complex collective dynamics whose self-organization principles are largely unknown. The influence of hydrodynamics on such collectives has been relatively unexplored theoretically, in part due to the difficulty in modeling the temporally long-lived hydrodynamic interactions between many dynamic bodies. We address this through a novel discrete-time dynamical system (iterated map) that describes the hydrodynamic interactions between flapping swimmers arranged in one- and two-dimensional lattice formations. Our 1D results exhibit good agreement with previously published experimental data, in particular predicting the bistability of schooling states and new instabilities that can be probed in experimental settings. For 2D lattices, we determine the formations for which swimmers optimally benefit from hydrodynamic interactions. We thus obtain the following hierarchy: while a side-by-side single-row "phalanx" formation offers a small improvement over a solitary swimmer, 1D in-line and 2D rectangular lattice formations exhibit substantial improvements, with the 2D diamond lattice offering the largest hydrodynamic benefit. Generally, our self-consistent modeling framework may be broadly applicable to active systems in which the collective dynamics is primarily driven by a fluid-mediated memory.