The general context is trying to understand the Picard groups of various schemes, but this question focuses on affine schemes.
Let $X=Spec A$ an affine scheme. What conditions does $A$ need to satisfy in order for $Pic X$ to be trivial? The equivalent algebraic formulation of the question is (it is equivalent for Noetherian rings): What conditions does a (Noetherian) ring $A$ need to satisfy in order for the following statement to hold -
Let $M$ be an $A$-module, such that for every prime $p\lhd A\quad M_p$ is free of rank $1$ over $A_p$. Then $M$ is a free $A$-module of rank $1$.
If someone could answer this, I'd be happy and pleased. In case it is too general up to now, here is a more specific version:
While reading a solution to a question I bumped into the following:
"Given a field $k$, the ring $k[t]$ is a PID, hence $Pic(Spec\:k[t])$ is trivial."
So I wonder: Is this statement true? If it is, how can it be proven? And what about the ring of polynomials in $n$ variables $k[t_1,\ldots,t_n]$, which is not a PID? Does the above statement hold for this ring?
Finally, I'm trying to get some geometric intuition for this matter. A basic result in differential topology is that any vector bundle over a contractible space is trivial. Does this have anything at all to do with the above question?
$\DeclareMathOperator{\Cl}{\operatorname{Cl}}$$\DeclareMathOperator{\Spec}{\operatorname{Spec}}$Here are some relevant results: let $R$ be a Noetherian domain.
i) (locally free of rank $1 \implies$ free of rank $1) \iff \Cl R = 0$ $(\iff \text{Pic}(\Spec R) = 0$, if $R$ is locally factorial)
ii) $R$ is a UFD iff $\Cl R = 0$ and $R$ is normal.
Now if $M$ is locally free of rank $1$, then $M$ is projective. By (ii), if $R$ is a UFD, then a rank $1$ projective is free - this resolves your specific case, namely $R = k[t_1, \ldots, t_n]$. If $R$ is not a UFD, one can find rank $1$ projectives that are not free, even if $R$ is locally factorial: e.g. $I = (2, 1 + \sqrt{-5}) \subseteq R = \mathbb{Z}[\sqrt{-5}]$.
The question for higher rank vector bundles is harder: the Quillen-Suslin theorem guarantees that any (f.g.) projective module over $k[t_1, \ldots, t_n]$ is in fact free. This says that vector bundles over affine space have algebraic trivializations, which is rather different from being topologically trivial.