The last form, as corrected by @metamorphy, follows from this fact: Given that an exponent $N$ on $x^{1/2}$ is congruent to $2\text{ mod }4$, the number of ways $N$ can be written as a sum of two squares (which are necessarily odd) is equal to the difference between the numbers of factors of $N$ congruent to $1$ and $3\text{ mod }4$. (Mathologer and 3Blue1Brown made videos on this, but the proof is not self-contained, as it relies on uniqueness of Gaussian prime factorization.) Then $N$ can be written as $2$ times that factor times another odd number, so the form $(-1)^mx^{(2m+1)(2n+1)}$ appears.
Continuing from there, we have
$$f(x)=\sum_{n=0}^\infty\sum_{m=0}^\infty x^{((2n+1)^2+(2m+1)^2)/2}$$
$$=\sum_{n=0}^\infty\sum_{m=0}^\infty x^{2n(n+1)+2m(m+1)+1}$$
$$=x\left(\sum_{n=0}^\infty x^{2n(n+1)}\right)^2$$
$$=x\left(\frac12\sum_{n\in\mathbb Z}x^{2n(n+1)}\right)^2$$
$$=x\left(\frac12\sum_{n\in\mathbb Z}(x^2)^n(x^2)^{n^2}\right)^2$$
and the Jacobi triple product formula gives
$$=x\left(\frac12\prod_{n=1}^\infty\big(1-x^{4n}\big)\big(1+x^{4n}\big)\big(1+x^{4n-4}\big)\right)^2$$
$$=x\left(\prod_{n=1}^\infty\big(1-x^{4n}\big)\big(1+x^{4n}\big)^2\right)^2.$$
This is sufficient, but I'll show its equivalence to the other answer:
$$=x\left(\prod_n\big(1-x^{8n}\big)\big(1+x^{4n}\big)\right)^2$$
$$=x\left(\prod_n\frac{\big(1-x^{8n}\big)\big(1-x^{8n}\big)}{\big(1-x^{4n}\big)}\right)^2$$
$$=x\left(\frac{\prod_{\text{even }n}\big(1-x^{4n}\big)\prod_{\text{even }n}\big(1-x^{4n}\big)}{\prod_{\text{odd }n}\big(1-x^{4n}\big)\prod_{\text{even }n}\big(1-x^{4n}\big)}\right)^2$$
$$=x\frac{\prod_{\text{even }n}\big(1-x^{4n}\big)^2}{\prod_{\text{odd }n}\big(1-x^{4n}\big)^2}.$$