Using algebraic long division we get:
x2 -2x +p-1
x2+2x+5 ) x4 +px2 +q
x4+2x3+5x2
-2x3+(p-5)x2
-2x3 -4x2 -10x
(p-1)x2 +10x + q
(p-1)x2+2(p-1)x+5(p-1)
0
Because the remainder has to be zero, 10-2(p-1)=0 and q-5(p-1)=0.
Therefore 12-2p=0, making p=6; and q=5(p-1)=25.
So x4+px2+q=x4+6x2+25=(x2+2x+5)(x2-2x+5)=x4-2x3+5x2+2x3-4x2+10x+5x2-10x+25.