\texttt{Let the current density be J} \\ \\ \mathrm{J=\frac{2I}{\pi a^2}}\\ \\
Now , consider this Cylinder
\texttt{Field at Point P1 due to this is } \\ \\ \mathrm{B_1=\frac{\mu_0 2I}{2\pi r}}
The direction is \mathrm{\hat{\theta}}
Now ,consider these two small cylinders one by one
But assume the current is going in the opposite direction
Due to the upper cylinder
\texttt{Field at Point P1 due to this is } \\ \\ \mathrm{B_2=\frac{\mu_0 I}{4\pi (r-\frac{a}{2})}}
Similarly ,consider the lower cylinder
\texttt{Field at Point P1 due to this is } \\ \\ \mathrm{B_3=\frac{\mu_0 2I}{4\pi (r+\frac{a}{2})}}
But B2 and B3 are in \mathrm{-\hat{\theta}}
So,net effet is
B1+B2+B3
B=\frac{\mu_0 I}{\pi}\left(\frac{1}{r}-\frac{1}{4}\left(\frac{1}{r-\frac{a}{2}}+\frac{1}{r+\frac{a}{2}} \right) \right)
Similarly , approach for 2nd one