Let $K$ be an algebraic number field and $\mathcal{O}_K$ the integral closure of $\Bbb{Z}$ in $K$. Let us recall that a Dedekind domain is a UFD iff it is a PID. Classically, I think that the questions concerning whether or not a certain Dedekind domain was a UFD were very important, see e.g. this thread here.
Perhaps from the point of view of algebra asking if something is a PID is easier to approach: we know how to factor ideals in Dedekind domains and thus there should at least be a tool to measure how far does a Dedekind domain differ from being a principal ideal domain.
Let me now give you an alternative definition of the ideal class group. We will put an equivalence relation on the set of all ideals defined as follows. We say that an ideal $I$ of $\mathcal{O}_K$ is equivalent to $J$ iff there is $\alpha,\beta \in \mathcal{O}_K$ so that
$$\alpha I = \beta J.$$
One easily checks that this is an equivalence relation. With a little bit more work, one can show that the set of all equivalence classes has a well defined multiplication law and is actually a group. The identity element being the class of all principal ideals. Now for some exercises.
Exercise 1: Check that the "class" of all principal ideals is actually a class. Namely if $I$ is an ideal such that $\alpha I = (\beta)$ then show that $I$ is actually principal. Hint: $\mathcal{O}_K$ is an integral domain.
Exercise 2: Show that this definition of an ideal class group is actually equivalent to the one given in Neukirch. Hint: Use the first isomorphism theorem.
Now do you see how the definition I have given you of an ideal class group actually measures nicely whether or not $\mathcal{O}_K$ is a PID? We see that $\mathcal{O}_K$ is a PID iff its ideal class group is trivial.
Now on to more interesting material. In advanced subjects such as Class Field Theory one can construct something know as the Hilbert Class Field of $K$. I don't know all the details of this construction as my algebraic number theory is not so advanced, but in the Hilbert class field every ideal of $\mathcal{O}_K$ becomes principal!! One can now ask the question: can we avoid talking of the Hilbert class field and find such an extension?
The answer is: Of course we can! This is where the ideal class group comes in. Firstly from Minkowski's bound we get that $Cl_K$ is actually a finite group. Using this, here are now two exercises which you can do:
Exercise 3: Let $I$ be an ideal of $\mathcal{O}_K$ show that there is a finite extension $L/K$ so that $I\mathcal{O}_L$ is principal. Hint: By finiteness of the class group there is an $n$ so that $I^n = \alpha$ for some $\alpha \in \mathcal{O}_K$. Now consider $L = K(\sqrt[n]{\alpha})$.
Exercise 4: Show that there is a finite extension of $L$ in which every ideal of $\mathcal{O}_K$ becomes principal. Wowowowowow!
Hint: Use exercise 3 and the definition of the ideal class group given in the beginning of my answer, not the one in Neukirch.
If you are stuck with any of these exercises I can post their solutions for you to view here.
Solution to Exercise 1 (As requested by user Andrew):
Suppose that $\alpha I = (\beta)$. Then in particular there is $x \in I$ so that $\alpha x = \beta$. We claim that $I = (x)$. Now it is clear that $(x) \subseteq I$. For the reverse inclusion take any $y \in I$. Then $\alpha y = \beta \gamma$ for some $\gamma \in R$. Since $\beta = \alpha x$ we get that
$$\alpha y = \alpha x \gamma.$$
But now $\mathcal{O}_K$ is an integral domain and so $y = x\gamma$, so that $I \subseteq (x)$. Hence $I = (x)$ and so $I$ is principal.
Let $X$ be a smooth connected projective curve over $\mathbb C$ of genus $g\gt 0$.
Since $X$ is smooth all local rings $\mathcal O_{X,x}$ are UFD's, but I claim that no affine open subset $U\subset X$ has a ring of regular functions $\mathcal O_X(U)$ which is a UFD.
Proof:
A subset $U\subset X$ is open and affine if and only it is obtained from $X$ by deleting a nonzero finite number of points from $X$ , namely $U=X\setminus \{x_1,\cdots,x_n\} \quad (n\geq 1)$.
The key tool is then the exact sequence $$\oplus _{i=1}^n\mathbb Z\cdot e_i \stackrel {u}\to \operatorname {Pic}(X) \stackrel {v}\to \operatorname {Pic}(U) \to 0 $$ in which the map $u$ sends the basis vector $e_i$ of the free module $\oplus _{i=1}^n\mathbb Z\cdot e_i$ to the line bundle $\mathcal O_X(x_i)$, while $v$ is just the restriction to $U$ of line bundles on $X$ . (Beware that $u$ nedn't be injective!)
This exact sequence can be found for $n=1$ in Hartshorne (Chapter II, Prop.6.5, page 133) and in Fulton's IntersectionTheory (Chap.1, Prop 1.8, page 21) for arbitrary $n$.
Since $\operatorname {Pic}(X)$ is non denumerable (for example because distinct points $x\in X$ give rise to distinct line bundles $\mathcal O_X(x)$ and $X$ is non denumerable since we are over $\mathbb C$) this proves that $\operatorname {Pic}(U)\neq0$.
And this allows us to conclude, as announced, that $\mathcal O_X(U)$ is not a UFD:
Indeed a noetherian domain $A$ is a UFD if and only if every prime ideal of height $1$ in $A$ is principal (Matsumura, Theorem 20.1, page 161) and that last condition translates for $A=\mathcal O(U)$ to every line bundle on $U$ being trivial.
Best Answer
Let $R$ be an arbitrary Dedekind domain, and choose some multiplicative set $S\subset R$. Let $\newcommand{\Pic}{\operatorname{Pic}}\Pic(R)$ denote the class group of $R$. Note that we have a map $\Pic(R)\to\Pic(S^{-1}R)$ sending a fractional ideal $M$ to its localization $\newcommand{\sinv}{S^{-1}}\sinv M$. We claim that this map is surjective, which suffices to show that $\Pic(A_2)=\Pic(A_3)=0$ in your example.
Pick $[M]\in\Pic(\sinv R)$, so $M$ is some finitely-generated $\sinv R$-submodule of $F=\operatorname{Frac}(R)$. We wish to show that $M=\sinv N$ for some finitely-generated $R$-submodule of $F$. Well, let $e_1,\dots,e_n\in M$ be a generating set, and take $N=\sum_{i=1}^nR e_i\subset M$. Then, $N$ is visibly a finitely-generated $R$-submodule of $F$, and we have $\sinv N=M$ by construction, so the map $\Pic(R)\to\Pic(\sinv R)$ is surjective and we win.