I apologize first for such a frequently asked question. I am not confident about my approach of this problem which is possibly related to glueing local isomorphisms. I am aware of that local isomorphisms do not always glue to global ones - otherwise all locally free sheaf of rank 1 will all be isomorphic. So I guess one needs to have a global morphism first to ensure the compatibility of local information.
Problem. Let $\pi:\operatorname{Spec}A\to \operatorname{Spec}B$ be a morphism of affine schemes and $M$ an $A$-module, hence $\widetilde{M}$ is a quasi-coherent sheaf on $\operatorname{Spec}A$. Give an isomorphism $\pi_*\widetilde{M}\cong \widetilde{M_B}$ where $M_B$ is simply regarding $M$ as an $B$-module via the ring map $\varphi:B\to A$ corresponding to the affine scheme morphism.
My approach. On the base $\{D(f)\}_{f\in B}$ of $\operatorname{Spec}B$, we have $$\alpha_{D(f)}:\pi_*\widetilde{M}(D(f))=\widetilde{M}(\pi^{-1}(D(f)))=\widetilde{M}(D(\varphi(f)))\cong M_{\varphi(f)}=(M_B)_f\cong\widetilde{M_B}(D(f))$$ which is compatible with restrictions. Because both $\pi_*\widetilde{M}$ and $\widetilde{M_B}$ are sheaves on $\operatorname{Spec}B$, they restrict to sheaves on the base $\{D(f)\}_{f\in B}$. Hence the $\{\alpha_{D(f)}\}_{f\in B}$ extends to a sheaf morphism (A possible reference is Lemma 6.30.14 https://stacks.math.columbia.edu/tag/009H) $\alpha:\pi_*\widetilde{M}\to \widetilde{M_B}$, which is actually an isomorphism since they give isomorphisms on the base.
I really find this confusing, which I am not sure if it is a psychological thing. Just in case, I am familiar with extending sheaves on a base using compatible germs. Any help is sincerely appreciated!
I have time now to write up an answer to your question; in short your proof is correct.
In the long, let $X$ be a topological space, $\mathcal B$ a basis for $X$, and $\mathcal F$ a sheaf on $X$. Then, the sheaf $\mathcal F_\mathcal B$ on $\mathcal B$ defined by $U\mapsto \mathcal F(U)$ for all $U$ in $\mathcal B$ induces a sheaf on $X$ which is uniquely isomorphic to $\mathcal F$. In particular, let $\theta^U_V$ denote the restriction maps for both sheaves, and sheaves on a basis, and $\psi_U$ denote the isomorphisms $\mathcal{F}(U)\rightarrow \mathcal F_\mathcal B(U)$, then $\mathcal F$ satisfies the following universal property:
Given this, $\textbf{for any pair of sheaves}$ on $X$, it suffices to define a morphism by only considering the morphism on a basis for $X$. In particular, if you want this to be isomorphism, then since the stalks satisfy $(\mathcal F_\mathcal B)_x\cong \mathcal F_x$ it suffices to check that your morphism on your basis is an isomorphism for all basic open sets.
Now, this is exactly what you have done so you are golden. What you have done does not imply that all locally free sheaves of rank $1$ over an affine scheme are isomorphic. Indeed, let $X=\operatorname{Spec} A$ for some ring $A$, and let $\mathcal L_1$ and $\mathcal L_2$ be line bundles over $\operatorname{Spec}A$. Then $\mathcal L_1$ and $\mathcal L_2$ are locally free of rank $1$, which tells us that there are covers $\{U_{f_i}\}$ and $\{U_{g_i}\}$ of $\operatorname{Spec}A$ by distinguished opens such that $\mathcal L_1|_{U_{f_i}}\cong A_{f_i}$, and $\mathcal L_2|_{U_{g_i}}\cong A_{g_i}$ as $A_{f_i}$ and $A_{g_i}$ modules. These covers do not need to be the same, so as far as I can tell, you cannot even write down a morphism between the two knowing this data alone.
Furthermore, since every locally free sheaf is clearly quasicoherent, and our scheme is affine, we have that $\mathcal L_1\cong \tilde{M}_1$ and $\mathcal L_2\cong \tilde{M}_2$ for some $A$ modules $M_1$ and $M_2$. The locally free condition, tells us that for every $\mathfrak{p}\in \operatorname{Spec}A$ there exists an $f\notin \mathfrak{p}$ such that $(M_1)_f\cong A_f$, which is exactly the condition that $M_1$ and $M_2$ are locally free modules, so the set of line bundles over an affine scheme is isomorphic to the class group of $A$, i.e. the group of isomorphism classes of locally free modules.
In essence, your proof does not show that the class group of $A$ is trivial, because when you have locally free modules, you do not have that $(M_1)_f\cong A_f\cong (M_2)_f$ for every $f\in A$, you only have it for some $f$, and these $f$'s need not be the same for both $M_1$ and $M_2$. In your proof, you have shown the much stronger condition that $\pi_*\tilde{M}$ and $\tilde{(M_B)}$ are isomorphic on all distinguished opens, not just a random cover, hence there is no contradiction between the two.
ETA:
In a lot of the easy examples, the class group of $A$ is trivial, I.e when $A=k[t]$ for some field $k$, or when $A=\mathbb Z$