I'm over all a little confused about base change in general, and also a little confused about what it means to be stable under base change. Let me highlight my confusion in the context of affine morphisms.
So, let $f:X\rightarrow Y$ be an affine morphism, and $g:Z\rightarrow Y$ be another morphism between schemes $X,Y,$ and $Z$. Now if I understand correctly, the base change of $X$ is the fibre product $X\times_Y Z$, and it is called a base change because we now have a morphism $X\times_YZ\rightarrow Z$ which is literally just the projection $\pi_Z$ from the fibre product to $Z$.
So if $f:X\rightarrow Y$ is an affine morphism, and then for affine morphisms to be stable under base change means that the projection map $\pi_Z:X\times_YZ\rightarrow Z$ is also an affine morphism.
(I think this is the correct way of thinking about this, if not please let me know)
To do this, we need only show that there exists an open cover affines $U_i$ in $Z$ such that $\pi^{-1}(U_i)$. So, let $z\in Z$, then there is an affine open neighborhood $V$ of $z$ which maps into an affine open neighborhood $U\subset Y$. By definition $f^{-1}(U)$ is affine, and so $\pi_X^{-1}(f^{-1}(U))=f^{-1}(U)\times_U Z$. Is there some reason that this should actually be $f^{-1}(U)\times_UV$? And if so, how do we then conclude that $\pi_Z^{-1}(V)$ is equal to $f^{-1}(U)\times_UV$? Since these are the only affines we have to work with I assume that this should be the form I am looking for, I just can't quite see how to get there.
There is a cube whose all faces are cartesian (this follows from abstract nonsense and has nothing to do with schemes).
The existence of such a cube follows from the fact that the fiber product $g^{-1}(U) \times_Y X$ is unique. Here I note that a composition of two cartesian squares is cartesian. So if you base change $f$ along $g$ then along $g^{-1}(U) \longrightarrow Z$, you get one fiber product (you go along the front face, then the left vertical face) and if you base change $f$ along $U \longrightarrow Y$ and then along $g^{-1}(U) \longrightarrow U$ you get another product (you go along the right vertical face and then the backward face) and hence two products must coincide.
I claim that from this you can reduce to the case where $X=\operatorname{Spec}(A),Y=\operatorname{Spec}(B)$ are both affine. Indeed, you can so that being affine is a local property on target. It means that a morphism $X \longrightarrow Y$ is affine if and only if there exists an open cover $Y = \bigcup U_i$, morphisms $f^{-1}(U_i)\longrightarrow U_i$ are affine. Indeed, one direction is obvious, suppose that there exists such a cover with each $f^{-1}(U_i) \longrightarrow U_i$ being affine. Note that each $U_i$ is a scheme so that we can decompose each $U_i$ into affine schemes and hence can suppose that $U_i$ themselves are affine. It then follows by this.
If you want to show that $\pi_X \colon X \times_Y Z \longrightarrow Z$ is affine so you must find a cover such that the restrictions of $\pi_X$ over its members are affine. If you let $Y = \bigcup U_i$ be an affine cover of $Y$, then $Z = \bigcup g^{-1}(U_i)$ would be such a cover.
In the case both $X,Y$ are affine, you can take any $W = \operatorname{Spec}(C) \subset Z$ affine, then we have cartesian squares $\require{AMScd}$ \begin{CD} \pi_Z^{-1}(W) @>>> X \times_Y Z @>>> X \\ @VVV @VVV @VVV \\ W @>>> Z @>>> Y \end{CD} but we can easily see that $\pi^{-1}_Z(W) = \operatorname{Spec}(A \otimes_B C)$ because a fiber product of affine schemes over an affine scheme is an affine scheme whose global sections is given by tensor product.