  The atomic and magnetic structures of (Cu$X$)LaNb$_2$O$_7$ ($X$=Cl and Br)
are investigated using the density-functional calculations. Among several
dozens of examined structures, an orthorhombic distorted $2\times 2$ structure,
in which the displacement pattern of $X$ halogens resembles the model
conjectured previously based on the empirical information is identified as the
most stable one. The displacements of $X$ halogens, together with those of Cu
ions, result in the formation of $X$-Cu-$X$-Cu-$X$ zigzag chains in the two
materials. The nearest-neighbor interaction within the zigzag chains are
determined to be antiferromagnetic (AFM) for (CuCl)LaNb$_2$O$_7$ but
ferromagnetic (FM) for (CuBr)LaNb$_2$O$_7$. On the other hand, the first two
neighboring interactions between the Cu cations from adjacent chains are found
to be AFM and FM respectively for both compounds. The magnitudes of all these
in-plane exchange couplings in (CuBr)LaNb$_2$O$_7$ are evaluated to be about
three times those in (CuCl)LaNb$_2$O$_7$. In addition, a sizable AFM
inter-plane interaction is found between the Cu ions separated by two NbO$_6$
octahedra. The present study strongly suggests the necessity to go beyond the
square $J_1-J_2$ model in order to correctly account for the magnetic property
of (Cu$X)$LaNb$_2$O$_7$.
