If you're trying to define what it means for a function to be regular on an open subset of an affine variety, you must you definition 2: a function is regular on this open subset iff it can locally be written as a ratio of polynomials with non-vanishing denominators.
In the special case where you're defining what it means for a function to be regular on the entire affine variety, this is equivalent to definition 1: a function is regular on the entire affine variety iff it can globally be written as a polynomial. And yes, I do mean "globally", not "locally".
The elements of $\mathscr{O}_{\mathbb{A}^n,a}$ are just rational functions $\frac{g}{f}$, where $f, g$ are polynomials of $n$ variables (i.e. elements of $\mathscr{O}_{\mathbb{A}^n}$) such that $f(a) \neq 0$.
This of course is nothing but a copy of Lemma 3.21 in your linked notes.
Intuitively, you should think about $\mathbb{A}^n$ as the $n$-dimensional complex space $\mathbb{C}^n$.
A polynomial $f\in \mathbb{C}[X_1, \cdots, X_n]$ then defines a function on $\mathbb{C}^n$: it sends a point $a = (a_1, \cdots, a_n)$ to $f(a_1, \cdots, a_n)$.
Now if $f, g\in \mathbb{C}[X_1, \cdots, X_n]$ are two polynomials, in general you cannot say that $\frac{g}{f}$ defines a function on $\mathbb{C}^n$, simply because the value of $f$ may vanish at some points.
But for a given point $a$, if we have $f(a) \neq 0$, then it's clear that $f$ does not vanish in a small neighborhood of $a$ (with respect to the usual topology of $\mathbb{C}^n$), hence on that small neighborhood we may define $\frac{g}{f}$ without problem.
And if we gather all functions that can be defined as $\frac{g}{f}$ in a small neighborhood of the given point $a$, we get the local ring $\mathscr{O}_{\mathbb{A}^n,a}$.
Best Answer
Let $i : X \to \Bbb P^r$ an embedding, then we can define $\mathcal O_X(n) = i^* \mathcal O(n)$. As you said, section of $\mathcal O_X(n)$ are quotients of homogeneous polynomials of appropriate degree, restricted to $X$.
In particular, any $f/g$ (as a function on $\Bbb P^r$) has poles on an hypersurface $Y \subset \Bbb P^r$.
If $X$ has positive dimension, then $Y \cap X \neq \emptyset$ and hence $f/g$ also has poles on $X$. It follows that $\mathcal O_X(n)$ has no global sections when $n < 0$, assuming $\dim X > 0$.