Let $f(x,y)=ax^2+bxy+cy^2$ be a quadratic form with integer coefficients. Let $b^2-4ac$ be its discriminant. If the discriminant is a perfect square then the quadratic form can be written as two linear forms.
I tried to complete the square (by multiplying with $4a$) to have the discriminant involved, but that didn't help :/.
Here is my thought on this: Completing the square:
$$z=ax^2+bxy+cy^2=a\left(x^2+\frac{b}{a}xy+\frac{c}{a}y^2\right)$$
Ignore the $a$ upfront for a moment. Continue:
$$\left(x+\frac{b}{2a}y\right)^2-\frac{b^2}{4a^2}y^2+\frac{c}{a}y^2=\left(x+\frac{b}{2a}y\right)^2-\frac{b^2-4ac}{4a^2}y^2$$
This can be factored as the difference of two squares IF $b^2-4ac$ is a perfect square. Can you finish from here?