EDIT: I have made a small change in terminology based on the suggestion by @BPP in the comments below.

This is an excellent question!

The subtlety here is that in high-school mathematics we are taught to freely move between **polynomials** and **polynomial functions**. But if we do not make the distinction between the two carefully, then confusions like in your question will arise.

When I have the equality $$\frac{1/2}{4/x} = \frac{x}{8}$$ there is no problem when viewing this is an equality of **rational fractions**, because in this case, there is no question of evaluating $x$, and hence no question of what the domains are, simply because they are not functions.

On the other hand, when I look at the equality $$\frac{1/2}{4/x} = \frac{x}{8}$$ as an equality of **rational functions**, then it is necessary that the domain of both functions are the same. Since the function on the left-hand side is defined for all $x \neq 0$, I can take that to be the domain of the function, and so the domain of the function on the right-hand side is also $\mathbb{R} \setminus \{0\}$.

*A lengthier explanation of this distinction follows below.*

## What is a polynomial?

Typically, it is taught at the high-school level that a **polynomial** (in one variable) is any expression of the form $$a_0 + a_1 x + \dots + a_n x^n$$ where $a_0,\dots,a_n$ are real numbers, and $n$ is a non-negative integer. We can denote this polynomial by $f(x)$. Here, $x$ is called a **variable** or **indeterminate**.

At the same time, we are also taught that we can substitute a real number, say $t$, for $x$ in order to *evaluate* the polynomial at $t$, and this is represented by $f(t)$. This is the point where the distinction between polynomials and polynomial functions should be made.

## What is a polynomial function?

For our purposes, we will stick to functions from real numbers to real numbers. We define a **polynomial function** to be a function $f: \mathbb{R} \to \mathbb{R}$ such that there exist real numbers $a_0,\dots,a_n$ so that $f(t) = a_0 + a_1 t + \dots + a_n t^n$ for every $t \in \mathbb{R}$.

## How are polynomials and polynomial functions the same?

At first glance, there may not appear to be much of a difference between polynomials and polynomial functions, for the following reason: given a polynomial $f(x) = a_0 + a_1 x + \dots + a_n x^n$ I can define a polynomial function $\tilde{f} : \mathbb{R} \to \mathbb{R}$ by $\tilde{f}(t) = a_0 + a_1 t + \dots + a_n t^n$ for each $t \in \mathbb{R}$. And, given a polynomial function $\tilde{g} : \mathbb{R} \to \mathbb{R}$ such that $\tilde{g}(t) = b_0 + b_1 t + \dots + b_m t^m$ for each $t \in \mathbb{R}$, I can define a polynomial $g$ by $g(x) = b_0 + b_1 x + \dots + b_m x^m$. This back and forth between polynomials and polynomial functions is compatible in the sense that the map $F$ from the space of polynomials (over $\mathbb{R}$ in one variable) to the space of polynomial functions (from $\mathbb{R}$ to $\mathbb{R}$) that sends the polynomial $f$ to the polynomial function $\tilde{f}$ by the above rule, **preserves the structure** of both spaces. More precisely, it satisfies the conditions:
$$
\begin{gather*}
f + g \mapsto \tilde{f} + \tilde{g}\\
cf \mapsto c\tilde{f}\\
fg \mapsto \tilde{f} \tilde{g}\\
1 \mapsto \operatorname{id}
\end{gather*}
$$
where $\operatorname{id}$ is the constant function $\operatorname{id}(t) = 1$ for all $t \in \mathbb{R}$. (As an aside, all this is often expressed by saying that the map $F$ given by $F(f) = \tilde{f}$ is an **isomorphism of algebras**.)

The fact that the function $F$ has these properties essentially means that polynomials and polynomial functions are not all that different.

## How are polynomials and polynomial functions different?

Despite the previous section, it is important to make a distinction between polynomials and polynomial functions for the following reason. When we divide a polynomial $f(x)$ by another polynomial $g(x)$ we get the **rational fraction** $f(x)/g(x)$. (Of course, $g(x)$ could divide $f(x)$ without leaving a remainder, in which case $f(x)/g(x)$ is in fact a polynomial, so every polynomial can also be considered a rational fraction.) Two rational fractions $f_1(x)/g_1(x)$ and $f_2(x)/g_2(x)$ will be considered equal if, after cancelling their common factors, we end up with the same expression in both cases. Or equivalently, the two rational fractions will be considered equal if $f_1(x) g_2(x) = f_2(x) g_1(x)$. Note that this is completely analogous to the definitions we make when talking about rational numbers.

Note that a rational fraction *is not a function* (since polynomials are not 'really' functions). However, we can define a **rational function** $h$ to be a function such that there exist real numbers $a_0,\dots,a_n$ and $b_0,\dots,b_m$ so that for every $t$ in the domain of $h$, we have $$h(t) = \frac{a_0 + a_1 t + \dots + a_n t^n}{b_0 + b_1 t + \dots b_m t^m}.$$

Clearly, I can repeat the same process as earlier: to every rational fraction I can associate a rational function, and to every rational function I can associate a rational fraction, in the obvious way. So, where does the problem arise?

The problem arises in the fact that two different representations of the same rational fraction can give rise to two different rational functions. For example, let $f(x) = x^2 - 4$, $g(x) = x-2$, $h(x) = x+2$ and $k(x) = 1$. Clearly, $f(x)/g(x) = h(x)/k(x)$. However, the function $u$ defined by $u(t) = f(t)/g(t)$ and the function $v$ defined by $v(t) = h(t)/k(t)$ are not the same function, because their domains are different! (I am assuming that all the functions have their domain as the maximal set on which they are defined. So, the domain of $u$ is $\mathbb{R} \setminus \{ 2 \}$ and domain of $v$ is $\mathbb{R}$.)

So, let's say we started with the rational function $v$. We construct the 'natural' rational fraction using $v$, namely $h(x)/k(x)$. We write $h(x)/k(x) = f(x)/g(x)$. Then we construct the rational function $u$ from the rational fraction $f(x)/g(x)$. But we end up with a different function! So, the realisation is that the 'evaluation map', which is basically 'replace $x$ by the real number $t$', is not an 'isomorphism' between the set of all rational fractions and the set of rational functions. Hence, we cannot move back and forth freely between the two notions unless we sort out how we want to define the evaluation map compatibly.

## How does all this answer the question?

When I have the equality $$\frac{1/2}{4/x} = \frac{x}{8},$$ this is certainly true when I view both sides as rational fractions. In this case, there is no question of evaluating $x$, and hence no question of what the domains are, simply because they are not functions.

On the other hand, when I look at the equality $$\frac{1/2}{4/x} = \frac{x}{8}$$ as an equality of rational functions, then it is necessary that the domain of both functions are the same. Since the function on the left hand side is defined for all $x \neq 0$, I can take that to be the domain of the function, and so the domain of the function on the right-hand side is also $\mathbb{R} \setminus \{0\}$.

The question, “Why am I able to make sense of the right-hand side at $x = 0$ and not able to make sense of the left-hand side at $x = 0$?” arises because we expect the evaluation map to be 'compatible', in some sense. That this is not so, is the content of the discussion above.

## What have I glossed over?

I have certainly been handwaving a bit when talking about isomorphisms, but this can be made fully precise without much trouble. All these ideas are discussed in any senior undergraduate course in algebra.

Also, as @AlexProvost commented below, I have defined a rational fraction to be a ratio of polynomials, and yet I am calling $\frac{1/2}{4/x}$ a rational fraction, despite $4/x$ not being a polynomial. Here, I have glossed over the fact that dividing a rational fraction by a rational fraction gives one a rational fraction. This can be shown quite easily, but I had still skipped this point.

Explanation of the edit: Earlier I had called ‘rational fractions’ as ‘rational functions’, and ‘rational functions’ as ‘functions that are rational’. I think the new terminology is cleaner, and I am not sure whether there is any standard terminology.