I got the answer x^2 + 49 from the question (x+7)^2.
But then i was told the answer was x^2 +14x+49.
could some explain the 14x pleas?
It [I assume you mean 14x not 40x] because $\displaystyle (a+b)^2 \neq a^2+b^2$
You need to either memorise the result, use the binomial theorem or use the distributive property/FOIL.
Using the distributive property $\displaystyle (x+7)^2 = (x+7)(x+7) = x(x+7) + 7(x+7) = (x^2+7x) + (7x+49) = x^2+14x+49$
Memorising that $\displaystyle (a+b)^2 = a^2+2ab+b^2$ is a great timesaver in exams