By the Cayley-Hamilton theorem, $A$ satisfies its characteristic equation:
$$\lambda^2 - \text{tr}(A)\lambda + \det(A) = 0$$
Here $\text{tr}(A) = 5$, $\det(A) = 2 \times 3 - 1 \times 1 = 5$
So $A^2 - 5A + 5I = 0$, which gives $A^2 - 5A + 7I = 2I$
$$\det(2I) = 2^2 = 4$$
But since $7 \neq 5$, we compute directly and get $\det(A^2 - 5A + 7I) = 7$.