Hello Vishnu V Gopal,
By remainder theorem since both have same remainder on dividing with x-2 we can write p(2) = q(2) (ie.., we can substitute 2 for x in both the equation and equate them)
p(2) = 2.2^3 +a.2^2+6-5 = 17 + 4a
q(2) = 2^3 + 2^2 -8 + a = 4+a
equating the 2 eqaution 17+ 4a = 4+a
a= -13/3