Rigidity and sharp stability estimates for hypersurfaces with constant and almost-constant nonlocal mean curvature