They are just using the constraints listed (i.e. p^2 < 2). Note that (p^2 - 2)/(p+2) = (p-2). It is just a clever way of picking a q such that you can pick a p that satisfies the properties for q (making q < p or p > q).
They picked a q in terms of a p where by they can apply the constraints and prove the result. The particular decomposition they used was picked solely to prove what they were intending to prove.