I assume there is an error in your DE, otherwise it would not be homogeneous. It should be:
x²y'=4x²+7xy+y².
Using your substitution y=ax, y'=a+xda/dx.
The DE becomes:
x²(a+xda/dx)=4x²+7ax²+2a²x²=x²(4+7a+2a²).
Assuming x≠0,
a+xda/dx=4+7a+2a², xda/dx=4+6a+2a²=2(2+3a+a²)=2(1+a)(2+a).
Now the variables can be separated:
da/(2(1+a)(2+a))=dx/x.
This can be expressed as partial fractions:
1/(2(1+a)(2+a))=½(A/(1+a)+B/(2+a)), where A and B are constants.
So A(2+a)+B(1+a)=1, 2A+B=1 (constant), A+B=0 (coefficient of x term), therefore B=-A, making 2A-A=1, that is, A=1, and B=-1. So we now have ½(da/(1+a)-da/(2+a))=dx/x.
Now we can integrate: ½ln|1+a|-½ln|2+a|=ln|cx| where c is a constant.
We can write this: ln|(1+a)/(2+a)|=ln(cx)², and equating the logs:
(1+a)/(2+a)=c²x².
Now put a=y/x:
(x+y)/(2x+y)=kx² where constant k=c².
The solution can be expressed in another form:
x+y=kx²(2x+y)=2kx³+kx²y,
y(1-kx²)=x(2kx²-1), y=x(2kx²-1)/(1-kx²).
QUICK CHECK
Let k=0, then y=-x is the solution. y'=-1 and the DE becomes:
-x²=4x²-7x²+2x², which is true.