Based on a prior question it turned out the roots of the polynomial
$$P(z) = z^2-a\,z-\frac{z}{a}+1$$ are determinded by $z_1 = a$ and $z_2 = 1/a$
Naively I fought the Polynomial can be hence factored by $$P_2(z) = > (z-a)\,(z-1/a)$$
However, this is wrong. The true factorization is given by $$P_1(z) = > (a-z)\,(a\,z-1)$$
It's quite puzzling me where that deviation comes from.
Edit
Really unfortunate:
For Whatever Reason I fought
$$P_1(z)= z+a^2\,z-a\,z^2-a$$
is the same as
$$P_2(z) = z^2-a\,z-\frac{z}{a}+1$$
However, here I had $P_2(z) = \frac{P_1(z)}{-a}$ expecting same factorization for both Polynomials from the program.
The reason for my expectation underlies the fact $P_1$ and $P_2$ have same roots. But their factorization is different? Also what's questionable: why it can't be fixed by multiplying $a$ back.
In your edit the problem is that both polynomial are different. When we divide $$P_1(z)= z+a^2\,z-a\,z^2-a$$ by $a$ we get
$$ \frac{z}{a}+az-z^2-1 $$
This was the error $1$.
Error $2$ - Also if there is a polynomial $ax+b$. If we divide it by $c$ we get $\dfrac{ax+b}{c}$. Remember that if you just divide a expression by some variable/constant the factorization would change. Remember like the case we took factorisation of $ax+b$ won't be same as $\dfrac{ax+b}{c}$. Similarly factorization of$$P_1(z)= z+a^2\,z-a\,z^2-a$$ is not same as factorization of $$ \frac{z}{a}+az-z^2-1 $$