You may know that, among the different ways to write the equation of a straight line, one of them is :
$$\tag{1}\dfrac{x}{x_0}+\dfrac{y}{y_0}=1$$
where $x_0$ is the abscissa of the intercept with the $x$ axis, and $y_0$ is the ordinate of the intercept with the $y$ axis.
(check for example that if $y=y_0$ then $x=0$ ; the same thing when $x=x_0$).
Then, as $x_0+y_0=k$, one may write (1) under the form:
$$\tag{2}\dfrac{x}{k-y_0}+\dfrac{y}{y_0}=1 \ \iff \ y = y_0(1 - \dfrac{x}{k-y_0}) \ \iff \ $$
$$\tag{3}y = \left(\dfrac{y_0}{y_0-k}\right)x+y_0$$
which depends on the single parameter $x_0$.
Now, if, in the left hand side of differential equation
$$\tag{4} \ (xy'-y)(y'-1)+ky'=0$$
we replace $y$ by (3) and $y'$ by $\left(\dfrac{y_0}{y_0-k}\right)$, it is easy to check that we obtain a right hand side in (4) which is $0$ (variable $y_0$ vanishes in the computation).
In a converse way, one could ask whether all solutions of the given differential equation are straight lines with equation (3).
You can neither express all lines in terms of a function $y(x)$ nor express all lines in terms of a function $x(y)$, since in each case there are lines that aren't described by such functions. This is a matter of the form in which you represent the functions, not of the differential equations that you impose on that form.
All lines can be represented in the form $(x(s),y(s))$, where $s$ is an arc length parameter, and in this representation the differential equation for lines is $\frac{\mathrm d^2}{\mathrm ds^2}(x(s),y(s))=0$.
Best Answer
Let $y=mx+c$. Working as you have done gives $$m+m^2x-mx-c=0\ .$$ Since this must be true for all $x$ we have $$m^2-m=0\quad\hbox{and}\quad m-c=0\ ,$$ which gives the possibilities $m=0$, $c=0$ or $m=1$, $c=1$. So there are two possible lines $$y=0\quad\hbox{and}\quad y=x+1\ .$$