I am supposed to show that the residue of $(f(z))^2$ at $\frac{\pi}{2}$, where $f(z) = \frac{e^z}{\cos z},$ is $2e^{\pi}$. Instead of using that $\mathrm{Res}\left[f^2, \frac{\pi}{2} \right] = \lim_{z \to \frac{\pi}{2}} = \frac{d}{dz}\left((z-\frac{\pi}{2})^2 f^2(z) \right)$ (which otherwise would be an option since $\frac{\pi}{2}$ is a double pole of $(f(z))^2$), it says I should begin by computing $f(z+\frac{\pi}{2})$ for $z$ close to $0$.
I don't understand why I should do this. Anyhow, I've tried it and can't seem to get it right. So
$$\frac{e^{z+\frac{\pi}{2}}}{\cos(z+\frac{\pi}{2})} = \frac{e^{z+\frac{\pi}{2}}}{-\sin(z)}= -e^{\frac{\pi}{2}}e^z z^{-1} (1-\frac{z^2}{6} + \mathcal{O}(z^4))^{-1} = -e^{\frac{\pi}{2}} (1+z+\mathcal{O}(z^2))z^{-1} (1-\frac{z^2}{6} + \mathcal{O}(z^4))^{-1} = -e^{\frac{\pi}{2}} (\frac{1}{z} + 1 + \mathcal{O}(z))(1-\frac{z^2}{6} + \mathcal{O}(z^4))^{-1} \iff f(z+\frac{\pi}{2}) = -e^{\frac{\pi}{2}}\left(\frac{1}{z} + 1 + \mathcal{O}(z) \right),$$ for $z$ close to $0$.
I am unsure what to do with $\mathcal{O}(z)$ when I go on to compute $(f(z+\frac{\pi}{2}))^2$, and so far haven't figured out a way to do it that gives the desired result.
Also, I would be grateful for some clarification regarding why I should be computing $f(z+\frac{\pi}{2})$ in the first place.
You replace $f(z)$ by $f(z+\pi/2)$ because it is easier to work with power series centered at $0$. The residue of $f$ at $\pi/2$ is the residue of $f(z+\pi/2)$ at $0$.
So your problem is to find the residue at $0$ of $$\Big(\frac{e^{(z+\pi/2)}}{\cos(z+\pi/2)}\Big)^2 = e^{\pi} \frac{e^{2z}}{\sin(z)^2} = e^{\pi} \frac{e^{2z} (z / \sin(z))^2}{z^2}.$$ As mentioned, this is easy to do with power series since $$e^{\pi} e^{2z} (z / \sin(z))^2 = e^{\pi} (1 + 2z + O(z^2)) (1 + O(z^2))$$ in which the relevant coefficient is $2e^{\pi}.$