The way I do this is to start with
$$p(x)=a_nx^n+a_{n-1}x^{n-1}+\cdots+a_1x+a_0\sim b_nx^n+b_{n-1}x^{n-1}+\cdots+b_1x+b_0=q(x).$$
If I want these to be equal I want their outputs to be equal and in particular at $x=0$:
$$p(0)\overset{!}{=}q(0)\Rightarrow a_0=b_0.$$
Also I want all of their derivatives to be equal if they are to be equal. Direct calculation shows that
$$\begin{align}
p'(x)&=a_1+\mathcal{O}(x)
\\ p''(x)&=2a_2+\mathcal{O}(x)
\\ \vdots&
\\ p^{(k)}(x)&=k!a_k+\mathcal{O}(x),
\end{align}$$
and similarly
$$q^{(k)}(x)=k!b_k+\mathcal{O}(x).$$
Setting
$$p^{(k)}(0)\overset{!}{=}q^{(k)}(0)\Rightarrow k!a_k=k!b_k\Rightarrow a_k=b_k,$$
for all $k$.