now this is where a bit of intuition comes into play. The symmetry in the coefficients makes me think of squared polynomial thus we have

g(a,b)=[h(a,b)]^2

now we can deduce that h(a,b) is a polynomial in a,b of degree two with 3 terms two of which are a^2 and b^2 and since the remaining terms of g(a,b) have a common factor of ab then the third term of h(a,b) must be ab