Answer: Using \(m_1 + m_2 = -\frac{2h}{b}\) and \(m_1 m_2 = \frac{a}{b}\) in \(\tan\theta = \left|\frac{m_1 - m_2}{1 + m_1 m_2}\right|\) gives the result; the lines are coincident when \(h^2 = ab\).
Let \(b \ne 0\) and let the lines be \(y = m_1 x\) and \(y = m_2 x\). Their combined equation is \((y - m_1 x)(y - m_2 x) = 0\), i.e. \(m_1 m_2 x^2 - (m_1 + m_2)xy + y^2 = 0\).
Dividing \(ax^2 + 2hxy + by^2 = 0\) by \(b\): \(\frac{a}{b}x^2 + \frac{2h}{b}xy + y^2 = 0\). Comparing, \(m_1 + m_2 = -\frac{2h}{b}\) and \(m_1 m_2 = \frac{a}{b}\).
\((m_1 - m_2)^2 = (m_1 + m_2)^2 - 4m_1 m_2 = \frac{4h^2}{b^2} - \frac{4a}{b} = \frac{4(h^2 - ab)}{b^2}\), so \(|m_1 - m_2| = \frac{2\sqrt{h^2 - ab}}{|b|}\).
Also \(1 + m_1 m_2 = 1 + \frac{a}{b} = \frac{a + b}{b}\).
The acute angle \(\theta\) between the lines satisfies \(\tan\theta = \left|\frac{m_1 - m_2}{1 + m_1 m_2}\right| = \left|\frac{2\sqrt{h^2 - ab}/b}{(a + b)/b}\right| = \left|\frac{2\sqrt{h^2 - ab}}{a + b}\right|\).
(If \(b = 0\), one line is \(x = 0\); working with slopes of \(x\) in terms of \(y\) gives the same formula.)
Condition for coincident lines: the lines coincide when \(\theta = 0\), i.e. \(\tan\theta = 0\), which gives \(2\sqrt{h^2 - ab} = 0\). Hence the required condition is \(h^2 = ab\).