If $a=0$ the result is clear. Take $a>0$ and take the closed rectangular contour $\Gamma$ counterclockwise oriented in the complex plane from $-T$ to $T$, a vertical segment from $T$ to $T+ia,$ a segment from $T+ia$ to $-T+ia $ and the last segment from $-T+ia$ to $-T$. Take $f(z)=e^{-z^2}.$ Then by Cauchy's theorem we have
\begin{align}
\oint_\Gamma f(z) \, dz = {} & 0\tag1 \\[8pt]
\text{ and } \oint_\Gamma f(z) \, dz = {} & \int_{-T}^Tf(x) \, dx + \int_0^a f(T+iy) \, dy \\
& {} + \int_T^{-T} f(x+ia) \, dx + \int_a^0 f(-T+iy) \, dy \\[8pt]
= {} &I_1+I_2+I_3+I_4.
\end{align}
As $T\rightarrow\infty$ we have $$I_1=\sqrt{\pi}$$ and for the second and fourth integral $$I_2=I_4=0$$ because $e^{-(x+ia)^2}\rightarrow0$ if $\left|x\right|\rightarrow\infty.$ And so by $(1)$
$$-I_3 = \int_{-\infty}^\infty f(x+ia) \, dx=\sqrt{\pi}.$$
If $a<0$ the proof is similar.