Characterization of Curves that Lie on a Geodesic Sphere or on a Totally Geodesic Hypersurface in a Hyperbolic Space or in a Sphere