Well-definedness of zeros and poles of rational functions in algebraic geometry My question is about the well-definedness of zeros and poles of rational functions following Vakil's Rising Sea (November 18, 2017 Edition).
On a regular codimension $1$ point $p$, we define the number of zeros resp. poles of an element $f \in \operatorname{Quot}(\mathcal{O}_{X,p})$ via the discrete valuation given by the DVR $\mathcal{O}_{X,p}$ (p. 353). In algebraic geometry, one then usually considers some rational function $s$ and tries to analyze the number of zeros and poles of $s$. I'm confused in how this makes sense, i.e. why is $s$ naturally an element in $\mathcal{O}_{X,p}$?
Let me also recall quickly the definition of rational functions in Vakil's book. On p. 171 we define a rational function on a scheme $X$ as an equivalence class of pairs $(U, s \in \Gamma(U, \mathcal{O}_X))$ where $\operatorname{Ass}(X) \subseteq U$. Two pairs $(U,s)$ and $(U',s')$ are said to be equivalent if $s|_{U \cap U'} = s'|_{U \cap U'}$. I'm guessing that my confusion stems from an insufficient understanding of associated points.

So to summarize: Given a rational function $s \in \Gamma(U,\mathcal{O}_X)$ with $\operatorname{Ass}(X) \subseteq U$, why is $s$ naturally an element of $\operatorname{Quot}(\mathcal{O}_{X,p})$ for all regular codimension $1$ points $p$?
 A: If $p\in X$ is a regular codimension one point, then it is in the closure of exactly one associated point $\eta$ of $X$ (ref), and in fact that point is the generic point of the unique irreducible component it is on. As the reduced locus is open in a noetherian scheme (ref), we can pick an integral affine open neighborhood $\operatorname{Spec} A\subset X$ of $p$. Then $\mathcal{O}_{X,p}$ is a localization of $A$, and $\mathcal{O}_{X,\eta}$ is the quotient field of $A$, so $\operatorname{Frac}(\mathcal{O}_{X,p})=\mathcal{O}_{X,\eta}$.
Now suppose $U\subset X$ contains all the associated points of $X$. Let $p\in X$ be a regular codimension one point and $\eta$ the unique associated point of $X$ which is a generalization of $p$. Then $s\in\mathcal{O}_X(U)$ maps to $\mathcal{O}_{X,\eta}$ by restriction, and as $\mathcal{O}_{X,\eta}=\operatorname{Frac}(\mathcal{O}_{X,p})$ we've explained what you were interested in.

Let me note a couple of small imprecisions in your question, just in case these were contributing to some of your troubles.

... I'm confused in how this makes sense, i.e. why is $s$ naturally an element in $\mathcal{O}_{X,p}$?

You stated this incorrectly here, but correctly after the line break: $s$ is naturally an element of $\operatorname{Frac}(\mathcal{O}_{X,p})$, not $\mathcal{O}_{X,p}$.

... Given a rational function $s \in \Gamma(U,\mathcal{O}_X)$ ...

It would be more precise to say "a rational function represented by $s\in\Gamma(U,\mathcal{O}_X)$".
