I fail to understand why the Factor command behaves differently in the third case:
Factor[a^2 + 2 a b + b^2] ,Factor[x^2 + 2 x Sqrt[y] + y] ,Factor[p^2 + 2 p Sqrt[q + r] + q + r]
Dear Daniel Thanks for the reply
Mathematica does not factor over arbitrary algebraic extensions. The one needed in this case would be say Q[Sqrt[p+q]]. Mathematica does support factoring over algebraic number fields though (things like Q[Sqrt[2]]). The actual oddity is that the second example "works". This is an artifact of internal implementation details wherein y and Sqrt[y] are represented internally as something like internalvariable[sqrty]^2 and internalvariable[sqrty] respectively (that's not the real naming but you get the idea).
Q[Sqrt[p+q]]
y
Sqrt[y]
internalvariable[sqrty]^2
internalvariable[sqrty]