I was given the question:
Prove that if $x$ is irrational, then $\frac1x$ is irrational
I did this through contraposition, namely:
if $\frac1x$ is rational, it can be written in the form $\frac ab$ where b is nonzero.
Thus, $\frac1x = \frac ab$ which gives $ x = \frac ba$, so $x$ is also rational, hereby indirectly proving that the original statement is true.
I couldn't find this proven in the way I did when looking for it on the internet, so where did I go wrong?
Your reasoning is correct,
and merits a bit more precision: You should not ignore zero as mentioned in a comment, e.g. by writing
If $\frac1x$ is a nonzero rational, it can be written in the form $\frac ab$ where both $a,b$ are nonzero.
Multiplicative inversion $\iota:\mathbb R\backslash\{0\}\to\mathbb R\backslash\{0\}, x\mapsto\tfrac1x$ is invertible, being its own inverse: $\iota^{-1}=\iota\,$.
It maps $\,\mathbb Q\backslash\{0\}\,$ to itself, whence it maps the irrationals $\,\mathbb R\backslash\mathbb Q\,$ to itself as well.