Total cross sections, angular distributions, and invariant-mass distributions have been measured for the photoproduction of $pi^0pi^0$ pairs off free protons and off nucleons bound in the deuteron. The experiments were performed at the MAMI accelerator facility in Mainz using the Glasgow photon tagging spectrometer and the Crystal Ball/TAPS detector. The accelerator delivered electron beams of 1508 and 1557~MeV, which produced bremsstrahlung in thin radiator foils. The tagged photon beam covered energies up to 1400~MeV. The data from the free proton target are in good agreement with previous measurements and were only used to test the analysis procedures. The results for differential cross sections (angular distributions and invariant-mass distributions) for free and quasi-free protons are almost identical in shape, but differ in absolute magnitude up to 15%. Thus, moderate final-state interaction effects are present. The data for quasi-free neutrons are similar to the proton data in the second resonance region (final state invariant masses up to $approx$1550~MeV), where both reactions are dominated by the $N(1520)3/2^-rightarrow Delta(1232)3/2^+pi$ decay. At higher energies, angular and invariant-mass distributions are different. A simple analysis of the shapes of the invariant-mass distributions in the third resonance region is consistent with strong contributions of an $N^{star}rightarrow Nsigma$ decay for the proton, while the reaction is dominated by a sequential decay via a $Deltapi$ intermediate state for the neutron. The data are compared to predictions from the Two-Pion-MAID model and the Bonn-Gatchina coupled channel analysis.