What does it mean to take the ratio of two equations? 
The line joining the origin and the point of intersection of the curves $ax^2+2hxy+by^2+2gx=0$ and $a_1x^2+2h_1xy+b_1y^2+2g_1x=0$ will be mutally perpendicular if $g(a_1+b_1)=g_1(a+b)$

This is solved in my reference as
$$
ax^2+2hxy+by^2=-2gx\\
a_1x^2+2h_1xy+b_1y^2=-2g_1x\\
\color{red}{\frac{ax^2+2hxy+by^2}{a_1x^2+2h_1xy+b_1y^2}=\frac{g}{g_1}}\\
x^2(ag_1-a_1g)+2xy(hg_1-h_1g)+y^2(bg_1-b_1g)=0\\
\text{lines are perpendicular }\implies ag_1-a_1g+bg_1-b_1g=0\\
(a+b)g_1=(a_1+b_1)g
$$
Mathematical steps are fine but I really do not understand the logic behind it, particularly the first two steps where we take the ratio of the two equations of the given curves ?
Intuition
Say, we have two lines $x+y=1$ and $x-y=-2$, we can solve it by substituting $y=x+2$ in $x+y=1\implies x+y=x+x+2=2x+2=2(x+1)=1\implies x=\dfrac{1}{2}-1=\dfrac{-1}{2}\implies y=\dfrac{3}{2}$.
But, If I do
$$
y=1-x\quad;\quad y=x+2\\
1=\frac{-x+1}{x+2}\implies x+2=-x+1\implies2x=-1\implies x=-1/2\\
y=3/2
$$
So what does it mean to take the ratio of two equations ?

The step you are concerned with is justified by the simple fact that division is a well-defined binary operation on the real numbers, assuming that the denominator is nonzero. To be precise:

Given $r,s,t,u \in \mathbb R$, if $r=t$ and if $s=u \ne 0$ then $\frac{r}{s} = \frac{t}{u}$.

In your problem, you have two equations of real numbers that you are assuming to be true, namely 
$$ax^2+2hxy+by^2+2gx=0 \qquad a_1x^2+2h_1xy+b_1y^2+2g_1x=0
$$
Therefore the following two equations are true:
$$\underbrace{ax^2+2hxy+by^2}_r=\underbrace{-2gx}_t \qquad \underbrace{a_1x^2+2h_1xy+b_1y^2}_s=\underbrace{-2g_1x}_u
$$
So you can now apply well-definedness of division.
However, having said that, it is still necessary to assume that $g_1$ is nonzero. I suspect it is a hidden hypothesis for your question that both $g$ and $g_1$ are nonzero, or maybe the case $g_1=0$ can be handled by a separate argument.
It is also necessary to assume that $x \ne 0$. Again, maybe the case that $x=0$ should be handled by a separate argument.
