At the risk of being overly simple, and this not really being a physics concept (but a very important concept, nonetheless, for doing physics): The set of functions which make up a polynomial, $$\left\{x^0, x^1, x^2, x^3, x^4, ... \right\},$$form a set of linearly independent functions. What that means is that you can't take any single one (or a pair, for that matter) and use a combination of the remaining others to make an exact copy of that one (or pair) which works for all values of $x$. In other words $$x^2=a+bx+dx^3 + ex^4 + gx^5 + ...$$ is an impossible equation if it's required to be true for any value of $x$.
So, with an equation like $$(ax^2-5)x= d+fx+gx^2+hx^3,$$ for all $x$, then$d=0$, $f=-5$, $g=0$, and $h=a$.