In short, it's because a function is all about the rule and domain of definition.
For example, let's consider the real-valued functions $f(x)=\frac{x^2}{x}$ and $g(x)=x$, with their maximal real domains of definition. In particular, then, $\mathrm{dom}(f)=\Bbb R\smallsetminus\{0\}$ and $\mathrm{dom}(g)=\Bbb R$. That means that $f$ and $g$ are not the same function, since their domains are not the same. Now, where both are defined, the rule is the same. However, this isn't enough for them to be the same function. Now, $f$ is a restriction of $g$ (specifically, to $\Bbb R\smallsetminus\{0\}$), so they are certainly related functions.
Edit: In the context of your previous question (regarding limits and restrictions), it is worth noting that $f$ can be continuously extended to $g$, since for any $\varepsilon>0$ there exists $\delta>0$ (in particular, in this case, $\delta=\varepsilon$) such that for any $0<|x|<\delta$ we have $\left|f(x)-0\right|<\varepsilon$.