I'm responding separately to several questions about "how" or "why" synthetic division works. This topic is often not presented very elegantly in high school math classes, which makes it seem more mysterious (and simultaneously more mundane) than it actually is.
It's easy enough to see how this algorithm mirrors the steps of polynomial long division, and because it uses the root $a$, instead of the divisor $(x-a)$, the algorithm involves addition rather than subtraction to find each intermediate remainder. But things get more interesting when the steps are interpreted as repeated application of the Remainder Theorem.
Using Horner's form, as shown in the question, it's quite straightforward to see that the end result is $p(a)$, and by the Remainder Theorem, that this would be the remainder for $\frac{p(x)}{x-a}$. What's not so clear is why the intermediate results are the coefficients of the quotient polynomial. Turns out, it's just repeated application of the Remainder Theorem, taken one step at a time.
There are two critical keys to understanding how synthetic division builds upon the Remainder Theorem. The first is Horner's form of the polynomial (a.k.a. the nested form), which is absolutely essential. It is instructive to consider the efficiency of computation ($n$ multiplications and $n$ additions to evaluate a polynomial of degree $n$) for synthetic substitution, versus direct evaluation of the polynomial at $x=a$ using the order of operations. It is an efficient algorithm.
The second key to understanding why this works is to be absolutely clear on what is meant by "synthetic substitution." Substitution is performed one "$x$" at a time, moving from left to right, in the nested form of the polynomial. So at each step, the first two remaining terms are regrouped as the product of a linear factor $(Ax + B)$ and a power of $x$. Then, the Remainder Theorem is applied to just the linear factor, by substituting $a$ for that one (and only that one) $x$. Other instances of $x$ remain unresolved, and that's how each result becomes a coefficient in the quotient polynomial.
When $(Ax + B)$ is divided by $(x-a)$, the quotient is $A$ (because $x-a$ is monic), and the remainder is $Aa + B$ (by the Remainder Theorem). For each successive term, the remainder from the prior operation becomes the leading coefficient for the next linear factor, which then undergoes the same treatment. Each successive linear factor is multiplied with a power of $x$, with the power decreasing each step.
Division of each new linear factor by $x-a$ means its leading coefficient goes to the next term of the quotient, and substitution of $x=a$ in that linear factor produces the next remainder coefficient. That number will become the leading coefficient and hence the coefficient for the next quotient term in the following step, producing yet another remainder, and so on, until the final remainder is reached.
Consider $p(x)=x^3+4x^2−5x+5$, as given in the question.
The first step involves $(x+4)x^2$ (leaving off the other terms), and we apply the Remainder Theorem on the factor $x+4$. So, $\frac{x+4}{x-a}$ yields quotient $1$ and remainder $a+4$. Multiplying back the $x^2$, the full quotient term becomes $x^2$, and the full remainder term is $(a+4)x^2$.
Next, the $-5x$ term is incorporated, and the prior remainder becomes part of a refactored term $((a+4)x-5)x$. Dividing the left factor by $x-a$ produces quotient $a+4$ and remainder $(a+4)a-5$. Multiplying back the factor $x$ on the right gives us the actual quotient term $(a+4)x$ and remainder term $((a+4)a-5)x$.
Finally, incorporating the constant term $5$, we have remaining $\frac{((a+4)a-5)x+5}{x-a}$, which gives us the trailing quotient term $(a+4)a-5$ and the final remainder $((a+4)a-5)a+5$. Putting all of this together, the complete quotient is $x^2+(a+4)x+((a+4)a-5)$. Notice how $a$ was substituted for $x$ one degree at a time, as we proceeded through each term of the original polynomial.
When $a=3$, this quotient becomes $x^2+7x+16$ with remainder $53$.
Best Answer
We write $$x^3 + x^2 - 7 ≡ (Ax^2 + Bx + C)(x-3) + D.\tag{1}$$ Put $x=3$. That conveniently kills all but $D$ on the right. Substituting on the left, we get that $D=3^3+3^2-7=29$. We can continue making other simple substitutions, and get linear equations that determine our coefficients.
But you asked about comparing coefficients. That is done as follows. Expand the right-hand side of (1). So in particular, multiply out $(Ax^2 + Bx + C)(x-3)$. We get after a while that the right-hand side is equal to $$Ax^3 +(-3A+B)x^2 +(-3B+C)x -3C+D.$$
This has to be the same polynomial as $x^3+x^2-7$.
So the coefficients of $X^3$ must be the same. That means $A=1$.
The coefficients of $x^2$ must be the same. That means $-3A+B=1$.
The coefficents of $x$ must be the same. That means $-3B+C=0$.
And the constant terms must be the same. That means $-3C+D=-7$.
Now solve. We already know $D=27$ a "quickie" way. The rest of the coefficients are now easy to pick up.