Assume $A$ is a noetherian local ring with $\mathfrak{m}_y$ being the unique maximal ideal and $\dim A=0$. We have the exact sequence $$0\to \mathfrak{m}_y\to A\to k(y)\to 0,$$ where $k(y)$ is the residue field $A_{\mathfrak{m}_y}/\mathfrak{m}_y$.
Let $B$ be a finitely generated flat $A$-algebra by $\phi:A\to B$, then $$0\to \mathfrak{m}_y\otimes_A B\to B\to k(y)\otimes_A B\to 0$$ is an exact sequence of $A$-algebra. From the fact that $\dim A=0$, $\mathfrak{m}_y$ is nilpotent.
Let $\phi^{-1}(\mathfrak{p}_x)=\mathfrak{m}_y$ for a prime ideal $\mathfrak{p}_x$ in $B$. My question is: Why would this implies $$\dim (k(y)\otimes_A B)_{\mathfrak{p}_x}=\dim B_{\mathfrak{p}_x}?$$ An approach that I can think of is to consider the dimension of the objects in the second exact sequence above. But is it true that $\dim (\mathfrak{m}_{y}\otimes_A B)_{\mathfrak{p}_x}=0$ and does it make sense?
This question will be helpful in understanding Hartshorne III.9.5, the dimension formula of fiber of flat morphism.
As mentioned in the comments you need to use the fact that modding out by a niplotent ideal does not change the dimension. The reason is that a nilpotent ideal is contained in every prime ideal, or in other words the topological space defined by taking $\operatorname{Spec}$ are isomorphic (but not as schemes!).
Now $k(y)\otimes_A B\cong B/\mathfrak{m}_yB$ and $\mathfrak{m}_yB$ is nilpotent in $B$.
Thus your result follows.