Extracted from Pinter's Abstract Algebra, Chapter 27, Exercise B1:
Let $p(x) = x^6-6x^4+12x^2-11$, which we can transform into a polynomial in $\Bbb{Z}_3[x]$: \begin{align*} x^6+1 \end{align*} Since none of the three elements $0,1,2$ in $\Bbb{Z}_3$ is a root of the polynomial, the polynomial has no factor of degree 1 in $\Bbb{Z}_3[x]$. So the only possible factorings into non constant polynomials are \begin{align*} x^6+1 &= (x^3+ax^2+bx+c)(x^3+dx^2+ex+f) \end{align*} or \begin{align*} x^6+1 &= (x^4+ax^3+bx^2+cx+d)(x^2+ex+f) \end{align*} From the first equation, since corresponding coefficients are equal, we have \begin{align} x^0:\qquad & cf &= 1 \tag{1} \\ x^1:\qquad & bf + ce &= 0 \tag{2} \\ x^2:\qquad & af + be + cd &= 0 \tag{3} \\ x^3:\qquad & c + f + bd + ae &= 0 \tag{4} \\ x^5:\qquad & a + d &= 0 \tag{5} \\ \end{align} From (1), $c = f = \pm1$, and from (5), $a + d = 0$. Consequently, $af + cd = c(a + d) = 0$, and by (3), $eb = 0$. But from (2) (since $c = f$), $b + e = 0$, and therefore $b = e = 0$. It follows from (4) that $c + f = 0$, which is impossible since $c = f = \pm1$. We have just shown that $x^6 + 1$ cannot be factored into two polynomials each of degree 3.
For the second equation, however, $x^6+1=(x^2+1)^3$ in $\Bbb{Z}_3[x]$. So we cannot say $p(x)$ is irreducible over $\Bbb{Q}$ because $x^6+1$ is irreducible over $\Bbb{Z}_3$. What am I missing here?
You are entirely correct here. What you are missing is that the preceding argument shows that $p$ is not a product of two cubics in $\Bbb{Q}[x]$. After all, if it were, then in such a factorization $$p=(x^3+ax^2+bx+c)(x^3+dx^2+ex+f),$$ all coefficients are integers by Gauss' lemma, and hence this reduces to a factorization into cubics in $\Bbb{F}_3[x]$. But you have just shown that no such factorization exists.
So it remains to show that $p$ is not the product of a quadratic and a quartic in $\Bbb{Q}[x]$, and there are infinitely many other primes to try. For example, in $\Bbb{F}_7[x]$ you have $$x^6-6x^4+12x^2-11=x^6+x^4+5x^2+3.$$ A quick check shows that this polynomial has no roots in $\Bbb{F}_7$. Now proceed as before, expanding $$x^6+x^4+5x^2+3=(x^4+ax^3+bx^2+cx+d)(x^2+ex+f),$$ to show that no such factorization exists in $\Bbb{F}_7[x]$.
If you are comfortable with a little more abstract algebra, here is an approach that does not require such ad hoc calculations. First it is easy to see that in $\Bbb{F}_3[x]$ the polynomial $p$ factors as $$p=x^6+1=(x^2+1)^3,$$ where $x^2+1\in\Bbb{F}_3[x]$ is irreducible. It follows that every irreducible factor of $p$ in $\Bbb{Q}[x]$ has even degree. Now note that $p=h(x^2)$ where $h:=x^3-6x^2+12x-11\in\Bbb{Q}[x]$. A quick check shows that $h$ has no roots in $\Bbb{F}_7$, and therefore it is irreducible in $\Bbb{F}_7[x]$. This means the subring of the quotient ring $\Bbb{F}_7[x]/(p)$ generated by $x^2$ is a cubic field extension of $\Bbb{F}_7$, and therefore $p$ has an irreducible cubic or sextic factor. In the latter case $p$ is irreducible in $\Bbb{F}_7[x]$, and hence in $\Bbb{Q}[x]$ and we are done.
If $p$ has an irreducible cubic factor in $\Bbb{F}_7[x]$, then this is the reduction of an irreducible factor of $p$ in $\Bbb{Q}[x]$. As we saw before, the degree of this factor is even, so it is either quartic or sextic. Again, if it is sextic then $p$ is irreducible in $\Bbb{Q}[x]$ and we are done. If it is quartic then its reduction in $\Bbb{F}_7[x]$ is the product of a cubic and a linear factor. But $p$ has no roots in $\Bbb{F}_7$ because $p=h(x^2)$ and $h$ has no roots in $\Bbb{F}_7$, a contradiction.