$ f(\frac{x^2+1}{x^2})=x^2+\frac{1}{x^2}-2 \Rightarrow f(x)=?$ 
$ f(\frac{x^2+1}{x^2})=x^2+\frac{1}{x^2}-2 \Rightarrow f(x)=?$

I'm getting a wrong answer even though my solution looks valid to me:
Inverse of $(1+\frac{1}{x^2})$ is $(\frac{1}{{\sqrt{x-1}}})$, so I plug this expression in wherever I see $x$'s 
$$f(x)=(\frac{1}{{\sqrt{x-1}}})^2+(\sqrt{x-1})^2-2$$
Finally, I get $f(x)=\frac{(x-2)^2}{x-1}$ which is wrong according to the answer key. The answer should have been $x^2-4$
What am I doing wrong?

In my opinion your answer is correct. Mimicking your computations I got the same result.
Defining $t=\dfrac{x^2+1}{x^2}$ we got that $$x^2=\dfrac{1}{t-1}.$$ So
$$f(t)=f\left(\dfrac{x^2+1}{x^2}\right)=\dfrac{1}{t-1}+t-1-2=\frac{(t-2)^2}{t-1}.$$
This holds for any $t\in (1,\infty)$ assuming $x\in \mathbb R\setminus \{0\}.$
