It's an application of Fubini's theorem and the observation that the domain of integration is $\{(x,y) \mid 0 \le y \le x < \infty\}$ which can be written in two ways. You can apply Fubini here as your function is non-negative and for seeing the two ways it sometimes helps mwe to write the bounded integral as in integral over a characteristic function as follows ($\chi_A(x) = 1$ if $x \in A$, $0$ else):
\begin{align*}
\int_0^\infty \int_0^x f(x)\,dy\,dx
&= \int_0^\infty \int_0^\infty \chi_{[0,x]}(y)f(x)\, dy\,dx\\\
&= \int_0^\infty \int_0^\infty \chi_{[0,x]}(y)f(x)\,dx\,dy\\\
&= \int_0^\infty \int_0^\infty \chi_{[y,\infty)}(x)f(x)\,dx \,dy\\\
&= \int_0^\infty \int_y^\infty f(x)\,dx\,dy
\end{align*}