Stability of the isodiametric problem on the sphere and in the hyperbolic space