Neutron scattering has been used to investigate the magnetic ordering of the rare-earth ions in the ErBa2Cu4O8 and DyBa2Cu4O8 materials. For the Er system a simple three-dimensional (3D) antiferromagnetic structure is observed, in which the magnetic unit cell is twice the chemical unit cell along the a axis, with a Néel temperature TN0.49 K. In the vicinity of the Néel temperature, however, scattering characteristic of two-dimensional behavior, indicative of the strong anisotropy of the magnetic interactions, is observed. The magnetic anisotropy arises naturally from the crystal structure, as the c-axis spacing of the magnetic ions is 3 times the a-b spacing. 2D behavior is also observed in the Dy material near its Néel temperature of 0.9 K. However, the scattering in the Dy system does not cross over to the expected 3D Bragg peaks at low temperatures, but rather the 2D line shape persists to the lowest temperatures measured. We explain this result as originating from a geometric cancellation of interactions between c-axis layers for the specific Dy a-b spin configuration, which together with the weak intrinsic c-axis interaction renders the net interaction along the c axis much smaller than all other known --2D magnets.-- Hence the 2D and 3D ordering temperatures appear to be quite different for the Dy material. We anticipate that a similar cancellation of interactions is likely to occur in other RBa2Cu4O8 (R being a rare-earth element) systems.