Genus-2 curves and Jacobians with a given number of points