Very belated, but in the hope it's helpful to posterity:
If $U$ is a non-empty open subset of the complex plane, there is a well-defined condition for a complex-valued function $f$ in $U$ to be holomorphic, namely that the complex derivative
$$
f'(z_{0}) := \lim_{z \to z_{0}} \frac{f(z) - f(z_{0})}{z - z_{0}}
= \lim_{h \to 0} \frac{f(z_{0} + h) - f(z_{0})}{h}
$$
exists for every $z_{0}$ in $U$.
The basic idea of Riemann surfaces, or generally of structures on manifolds, is to extend concepts such as holomorphic functions in a coordinate-independent way.
For example, suppose we take two copies of the complex plane and identify an arbitrary non-zero complex number $z$ in one copy with the non-zero complex number $w = 1/z$ in the other copy. (Geometrically, the points $(z, 1)$ and $(1, w)$ lie on the same line through the origin, see the projective line below.) Because the complex reciprocal is holomorphic and bijective with holomorphic inverse (or biholomorphic) in the punctured plane, "$f(z)$ is holomorphic if and only if $f(w) = f(1/z)$ is holomorphic." (The quotes guard against fine print about domains, and the fact that really $f$ is holomorphic, not $f(z)$ or $f(w)$.)
The modern perspective is to take a disjoint union of two complex planes (labeled $V_{0}$ and $V_{1}$ in the linked diagram), impose the equivalence relation $z \sim w = 1/z$ as above, and to view the result as a topological space with the property that every point has a neighborhood modeled on an open set of the complex plane, and so that "holomorphic" is well-defined modulo the equivalence $\sim$. The resulting topological space has at least a few pleasant descriptions:
- The extended plane, namely the disjoint union of the complex $z$-plane with a single point where $w = 0$, which we interpret as $z = \infty$.
- The Riemann sphere, viewed as the one-point compactification of the plane via stereographic projection. (A bit of care is required to view the $w$-plane as the complement of $0$ in the sphere.)
- The complex projective line, i.e., the set of complex lines through $(0, 0)$ in $\mathbf{C}^{2}$, with the "non-vertical" line $w = mz$ corresponding to the complex number $m$, and the "vertical" line corresponding to $\infty$.
Now to the question: To check whether a function on an open subset of the sphere is holomorphic, we select a coordinate system $z$ or $w$, dictated by convenience if we're not at $z = 0$ ($w = \infty$) or $z = \infty$ ($w = 0$) and by necessity otherwise, represent our function in that coordinate, and ask if the resulting representation is holomorphic. Thanks to the biholomorphism between the overlapping parts of the $z$-plane and $w$-plane, the answer is well-defined (independent of the choice of coordinate).
You're right that $f(z)$ and $f(1/z)$ are different functions. On the other hand, if we identify $w = 1/z$, then modulo domain issues we can define a function $g$ by $g(w) = g(1/z) = f(z)$, and those are "the same."
Why is this useful? For one thing, it allows us to do complex analysis near $\infty$, and generally on a compact, boundaryless domain. It turns out that holomorphic functions on the sphere are uninteresting (because they're all constant; why?), but meromorphic functions and $1$-forms, and generally "holomorphic objects with isolated singularities," not only remain interesting, but naturally guide us into topology of surfaces.
To give a few representative examples:
- A non-constant polynomial function is meromorphic, with a pole at $\infty$ of order equal to the degree. For example, $1 + z^{2} = 1 + (1/w)^{2} = (w^{2} + 1)/w^{2}$ has a double pole at $z = \infty$.
- The entire function $\exp$ is not meromorphic, but has an essential singularity at $z = \infty$ because $\exp(1/w)$ has an essential singularity at $w = 0$.
- The meromorphic $1$-form $dz/z = -dw/w$ has simple poles at $0$ and $\infty$, and the sum of the residues is $0$, but has a non-meromorphic primitive, $\log$ viewed as a multi-valued function on the set of non-zero complex numbers. Integrating this $1$-form defines a topological covering map that turns out to be the universal cover of the punctured plane.