Magnetization-induced second- and third-harmonic generation in magnetic thin films and nanoparticles