[itex]x^2+ y^2+ z^2= 2az[/itex] when [itex]x^2+ y^2+ z^2- 2az= 0[/itex]. We can complete the square by adding [itex]a^2[/itex] to both sides: [itex]x^2+ y^2+ z^2- 2az+ a^2= x^2+ y^2+ (z- a)^2= a^2[/itex]. That is a sphere with center at (0, 0, a) and radius a. [itex]x^2+ y^2+ z^2= a^2[/itex] is, of course, a sphere with center at (0 0, 0) and radius a. The two spheres intersect when [itex](z- a)^2 - z^2= z^2- 2az+ a^2- z^2= a^2- 2az= 0[/itex] or [itex]z= a/2[/itex], in which case [itex]x^2+ y^2+ z^2= x^2+ y^2+ a^2/4= a^2[/itex] or [itex]x^2+ y^2= 3a^2/4[/itex]. That is, the intersection is a circle in the z= a/2 plane with center at (0, 0, a/2) and radius [itex]a\sqrt{3}/2[/itex].
In terms of spherical coordinates, each point on that circle of intersection has [itex]\rho= a[/itex] and [itex]\theta= arcsin(\sqrt{3}/2)= \pi/6[/itex]
The integral, then, should be done in two parts: For the first, [itex]\theta[/itex] goes from 0 to [itex]\pi/6[/itex] and, for each [itex]\theta[/itex], [itex]\rho[/itex] goes to the "upper sphere", [math]x^2+ y^2+ z^2= a^2[/math], from 0 to a.
For the second part, [itex]\theta[/itex] goes from [itex]\pi/6[/itex] to [itex]\pi/2[/itex] and, for each [itex]\theta[/itex], [itex]\rho[/itex] goes from 0 to the "lower" sphere [itex]x^2+ y^2+ z^2= 2az[/itex] which in polar coordinates is [itex]\rho^2= 2a\rho cos(\theta)[/itex]. That is, for each [itex]\theta[/itex], [itex]\rho[/itex] goes from 0 to [itex]2a cos(\theta)[/itex]. (Note that when [itex]\theta= \pi/6[/itex], [itex]cos(\theta)= 1/2[/itex] so that [itex]\rho= a[/itex].)
[itex]\phi[/itex] goes from 0 to [itex]2\pi[/itex] for both integrals.
(In order to be consistent with the original post, I have used "engineering" notation of spherical coordinates in which [itex]\theta[/itex] is the "co-latitude" and [itex]\phi[/itex] is the "longitude" rather than "mathematics" notation in which the two Greek letters are reversed. I have used [itex]\rho[/itex] rather than "r" because that is the convention in either system.)