Distinct and repeated distances on a surface and incidences between points and spheres