Why is this not allowed to solve a differential equation? How come you can't just integrate like this?$$y'=2y+x \implies y=2yx+\frac{x^2}{2}+C$$ 

Because $y$ is a function of $x$. Writing $y = f(x)$, then the first term on the right you are integrating is
$$\int 2y \ dx = \int 2f(x) \ dx$$
That term is equal to $2yx$ if and only if $f$ is a constant function. In general, such an assumption is dangerous as it could be wrong.
It is wrong in this case: if $f$ is a constant function then left hand side of the original ODE $y' = 0$. From which it follows $0 = 2y + x$ and thus $$y = f(x) = -x/2$$ which is not a constant. Contradiction.
