The original answer is correct. The mistake in the answer above is at the point where the -1 and -3 are substituted to find the value of k. The 1, in brackets on the rhs, should be -1.
Here's an alternative method of solution.
The solution consists of a Complementary Function (CF) which is the general solution of the homogeneous equation 2dy/dx + y = 0, plus a Particular Integral (PI), which is any solution of the complete equation 2dy/dx + y = x^2.
The CF is easily found to be A.exp(-x/2), where A is an arbitrary constant.
There are several methods for calculating a PI, easiest is probably by trial solution.
Let $$y=ax^2+bx+c,$$ so $$y'=2ax+b$$.
Substitute into the differential equation, and we have
$$2(2ax+b)+(ax^2+bx+c)\equiv x^2$$,
or, $$ax^2+(4a+b)x+(2b+c)\equiv x^2. $$
Now equate coefficients across the identity.
$$a=1,$$
$$4a+b=0,$$ so, $$b=-4,$$
$$2b+c=0,$$ so, $$c=8.$$
That means the general solution of the original ode is $$y = A\exp(-x/2)+x^2-4x+8,$$
and substituting the -1 and -3 gets $$A = -16 \exp(-1/2)\approx -9.70449.$$
.