We can simplify $\,d\mid n\,$ by replacing $\,n\,$ by $\,\bar n = n\bmod{d}\,$ (divisibility mod reduction),
namely recall that if $\bmod d\!:\ n\equiv \bar n\ $ then $\,\ \bbox[5px,border:1px solid #c00]{d\mid n\!\iff\! d\mid \bar n}\,\ $ Applied here:
$\bmod\, \underbrace{a-2}_{\color{#c00}{\textstyle a\equiv 2}}\!:\ $ $\,\underbrace{\color{#c00}a^3\!+\!4\equiv \color{#c00}2^3\!+\!4}_{\textstyle\color{#0a0}{f(a)\equiv f(2)}}\equiv 12,\,\ $ so $\ \ \bbox[5px,border:1px solid #c00]{a\!-\!2\mid a^3\!+\!4\!\iff\! a\!-\!2\mid 12}$
$\bmod\, \underbrace{a-2}_{\color{#c00}{\textstyle a\equiv 2}}\!:\ $ $\ \ \color{#0a0}{f(a)\equiv f(2)},\ \ $ therefore $\,\ \ \bbox[5px,border:1px solid #c00]{a\!-\!2\mid f(a)\!\iff\! a\!-\!2\mid f(2)}$
where we used: $\ \color{#0a0}{f(a)\equiv f(2)}\pmod{\!a\!-\!2}\,$ for any polynomial $\,f(x)\,$ with integer coefficients, by the Polynomial Congruence Rule (or the Polynomial Remainder Theorem). Using congruences as above is generally much simpler than using long-division, since here we don't need the quotient $\,f(a)\div (a\!-\!2),\,$ just its remainder $f(a)\bmod (a\!-\!2)\,$ [$ = f(2),\,$ a simple polynomial evaluation].
Generally this easily extends to the nonmomic primitive case: for $\,f(x)\in\Bbb Z[x]\,$ of degree $\,d$
$${\rm if}\,\ \gcd(j,k)\!=\!1\,\ {\rm then}\,\ \ \bbox[1px,border:1px solid #c00]{\bbox[6px,border:1px solid #c00]{k\:\!\:\!a\!-\!j\mid f(a) \!\iff\! \, k\:\!\:\!a\!-\!j\mid k^d f \left({\small \frac{j}k}\right)\in\Bbb Z}}\qquad\qquad\quad$$
where the scaling by $\,k^d\,$ serves to keep the arithmetic fraction-free.