Consider the following integral, $$I=\int_{-\infty}^\infty\frac{f(x)}{x^2-a^2}dx,$$
This can be solved using complex analysis by using Feynman's $i\epsilon$ prescription, \begin{align} I&=\lim_{\epsilon\rightarrow0}\int_{-\infty}^\infty\frac{f(x)}{x^2-a^2+i\epsilon}dx\\ &=\lim_{\epsilon\rightarrow0}\int_{-\infty}^\infty\frac{f(x)}{2a}\left[\frac{1}{x-(a-i\epsilon)}-\frac{1}{x-(-a+i\epsilon)}\right]dx\\ &=-\frac{2\pi i}{2a}f(-a), \end{align}
where we have chosen the contour as a semicircle of radius $R$ in the upper half-plane and taken the limit $R\rightarrow\infty$, assuming that $f$ is such that the integral over the arc vanishes at infinity. Since the only pole inside the contour is the one at $-a$, this is the only residue that contributes.
Now, instead of displacing the poles, consider deforming the contour as follows,
Then, $I$ can be obtained by integrating over the above contour (let's call it $C$) and taking the radius $R$ of the large semicircle to $\infty$, and the radii $\epsilon$ of the small semicircles (call them $S_1$ and $S_2$) to $0$. Again, the integral over the big semicircle vanishes, and \begin{align} I&=\int_C-\int_{S_1}-\int_{S_2}\\ &=-\frac{2\pi i}{2a}f(-a)+\pi i\frac{f(-a)}{2a}+\pi i\frac{f(a)}{2a}\\ &=\frac{2\pi i}{2a}\left(\frac{f(a)-f(-a)}{2}\right), \end{align}
where we have used the residue theorem, and the corollary in this answer.
Why do the results differ?
Edit: My question is close to this one, but not quite the same, since I have deformed the contour in the same direction I've shifted the poles. According to the answer in that question, I should then get the same result with both methods, but I don't.