Let's work over $\mathbb{R}$ first. The space of all lines in $\mathbb{R}^2$ (meaning one-dimensional subspaces) is called the real projective line $\mathbb{RP}^1$, and it can be constructed by putting the equivalence relation $v\sim \lambda v$ (for all nonzero scalars $\lambda\in\mathbb{R}^\times$) on $\mathbb{R}^2\setminus0$, then collecting together the equivalence classes.
For most points, we have $(x,y)\sim (x/y,1)$. Except for those of the form $(x,0)\sim(1,0)$. We can define a bijection $\mathbb{RP}^1\leftrightarrow\mathbb{R}\cup\{\infty\}$ by asociating $(x,y)$ with $x/y$ if it exists and $(x,0)$ with $\infty$ otherwise. Note that topologically, this looks like a circle $S^1$. One can treat $S^1$ minus a point as $\mathbb{R}$ and then the missing point is called $\infty$.
Any linear transformation $(\begin{smallmatrix}a&b\\c&d\end{smallmatrix})\in\mathrm{GL}(2,\mathbb{R})$ sends lines to lines, so it "acts" on $\mathbb{RP}^1$. How does the corresponding action look on $\mathbb{R}\cup\{\infty\}$? Well, we have
$$\begin{pmatrix}a&b\\c&d\end{pmatrix}\begin{pmatrix} x\\y\end{pmatrix} =\begin{pmatrix} ax+by \\ cx+dy \end{pmatrix} $$
so the action on the corresponding elements of $\mathbb{R}\cup\{\infty\}$ will be
$$ \begin{pmatrix}a&b\\c&d\end{pmatrix}\cdot\frac{x}{y} =\frac{ax+by}{cx+dy} $$
or in other words
$$ \begin{pmatrix}a & b \\ c & d \end{pmatrix} z=\frac{az+b}{cz+d} $$ using $z=x/y$. Note that division by $0$ is interpreted as giving $\infty$, and $0/0$ will never happen since we used an invertible matrix.
The same thing can be done with $\mathbb{C}$ (or even the quaternions $\mathbb{H}$, although then one must be careful since multiplication and division are not commutative operations), in which case $\mathbb{C}\cup\{\infty\}$ is called the Riemann sphere.
Also notice this is a group action. That means given any two $A,B\in\mathrm{GL}(2,\mathbb{C})$ and $z\in\mathbb{C}\cup\{\infty\}$, we have $A\cdot (B\cdot z)=(AB)\cdot z$, where $AB$ is just usual matrix multiplication.