The first algebra question in IMO 2018 is:
Let $\mathbb{Q}_{>0}$ denote the set of all positive rational numbers. Determine all functions $f\colon \mathbb{Q}_{>0} \to \mathbb{Q}_{>0}$ satisfying $$f\left(x^2 f\left(y \right)^2 \right) = f\left(x \right)^2f\left(y \right)$$ for all $x, y \in \mathbb{Q}_{>0}.$
In the first part of the solution they say:
Take any $a, b \in \mathbb{Q}_{>0}.$ By substituting $x = f\left(a \right) \dots$
This is where my issue is, the question asks you to prove for all $x \in \mathbb{Q}_{>0}$. Wouldn't substituting $x$ for $f\left(a \right)$ only be justified if $f$ was a bijective function?
There is no issue with the substitution.
The identity holds for all rational $x$. Since $f(a) $ is a rational number, we're allowed to set $ x = f(a)$.
We are saying "For all $a$, we have $x = f(a)$ and thus...
We are not saying that "For all $x$, there exists an $a$ such that $ x = f(a)$."
Yes, it might be that the image of $ f(a) $ isn't $\mathbb{Q}$.
(In particular, since the only solution is $f(x) = 1$.)