*Very* late to this party, but I've recently started studying this, and I've found an answer that is quite satisfying to me (at least satisfying enough for me to continue on). Specifically, we will use the fact that $M$ is a flat $A$-module if and only if $I\otimes_AM\cong IM$ for all ideals $I$ of $A$ (as Andrew does above).

Let $\pi:X\rightarrow Y$ be a morphism of schemes, let $V\hookrightarrow Y$ be any closed subscheme, and let $\mathcal{I}_{V/Y}$ be the quasicoherent sheaf of ideals carving out $V$. Considering $V\hookrightarrow Y$ to be a closed subfunctor, we can considering the corresponding closed subfunctor $V_X\hookrightarrow X$ to be the "preimage" of $V$ in $X$. The quasicoherent sheaf of ideals carving out $V_X\hookrightarrow X$ is exactly the image sheaf (call it $\mathcal{I}_{V_X/X}$) given by the morphism $\pi^*\mathcal{I}_{V/Y}:=\pi^{-1}\mathcal{I}_{V/Y}\otimes_{\pi^{-1}\mathcal{O}_Y}\mathcal{O}_X\rightarrow \mathcal{O}_X$, $i\otimes m\mapsto im$.

Using the fact that $\pi$ is flat is a stalkwise condition and the definition of flatness in terms of ideals, it is clear that $\pi^*\mathcal{I}_{V/Y}\cong \mathcal{I}_{V_X/X}$ for all $V\hookrightarrow Y$ if $\pi$ is flat. That is, a necessary condition for $\pi$ to be flat is that $\pi^*\mathcal{I}_{V/Y}\cong \mathcal{I}_{V_X/X}$ for all $V\hookrightarrow Y$.

It turns out, this condition is also sufficient! Indeed, choose any $[\mathfrak{q}]\in X$, and define $[\mathfrak{p}]:=\pi([\mathfrak{p}])$. Next, consider the canonical morphism $i:\text{Spec}\mathcal{O}_{Y,[\mathfrak{p}]}\rightarrow Y$. It's a general fact that the image of $i$ is contained in any open subset of $Y$ which also contains $[\mathfrak{p}]$ (Vakil 7.3.M), which in particular implies that $i$ is affine (choose any affine open $\text{Spec}A\hookrightarrow Y$. If $[\mathfrak{p}]\in \text{Spec}A$, then $\text{Spec}\mathcal{O}_{Y,[\mathfrak{p}]}\times_Y\text{Spec}A\cong \text{Spec}A_{\mathfrak{p}}\times_{\text{Spec}A}\text{Spec}A\cong \text{Spec}A_{\mathfrak{p}}$, and if $[\mathfrak{p}]\not\in \text{Spec}A$, then this is empty). Next, let $I$ be any ideal in $\mathcal{O}_{Y,[\mathfrak{p}]}$, and let $j:V\hookrightarrow \text{Spec}\mathcal{O}_{Y,[\mathfrak{p}]}$ be the corresponding closed subscheme. Then $j$ is affine, so $i\circ j$ is affine. In particular, $i\circ j$ is qcqs, so $(i\circ j)_*\mathscr{F}$ is quasicoherent on $Y$ for all quasicoherent sheaves on $V$, which implies that $(i\circ j)_*\mathcal{O}_V$ is quasicoherent on $Y$. Now consider the canonical map $\mathcal{O}_Y\rightarrow (i\circ j)_*\mathcal{O}_V$, which corresponds to the map $(i\circ j)^*\mathcal{O}_Y=(i\circ j)^{-1}\mathcal{O}_Y\otimes_{(i\circ j)^{-1}\mathcal{O}_Y}\mathcal{O}_V\rightarrow \mathcal{O}_V,\ y\otimes v\mapsto yv$ under the adjunction $(i\circ j)^*\vdash (i\circ j)_*$. Since $(i\circ j)_*\mathcal{O}_V$ is quasicoherent and the quasicoherent sheaves on $Y$ form an abelian category, so $\mathcal{I}:=\text{ker}(\mathcal{O}_Y\rightarrow (i\circ j)_*\mathcal{O}_V)$ is a quasicoherent sheaf of ideals on $Y$. Now, consider the stalk $\mathcal{I}_{[\mathfrak{p}]}$. This is the kernel of $\mathcal{O}_{Y,[\mathfrak{p}]}\rightarrow ((i\circ j)_*\mathcal{O}_V)_{[\mathfrak{p}]},$ where $((i\circ j)_*\mathcal{O}_V)_{[\mathfrak{p}]}=(i_*(j_*\mathcal{O}_V))_{[\mathfrak{p}]}=\Gamma(\text{Spec}\mathcal{O}_{Y,[\mathfrak{p}]},j_*\mathcal{O}_V)$, which is exactly $I$. We have now shown that for any point $[\mathfrak{p}]$ in the image of $\pi$ and any ideal $I$ of $\mathcal{O}_{Y,[\mathfrak{p}]}$, we can choose a quasicoherent sheaf of ideals $\mathcal{I}$ on $Y$ such that $\mathcal{I}_{[\mathfrak{p}]}\cong I,$ and our result follows.

Thus, $\pi:X\rightarrow Y$ is a flat morphism of schemes if and only if for all closed subschemes $V\hookrightarrow Y$ (carved out by a quasicoherent sheaf of ideals $\mathcal{I}$), the functions that vanish on $V_X\hookrightarrow X$ are exactly those of the form $\pi^{-1}\mathcal{I}_{V/Y}\otimes_{\pi^{-1}\mathcal{O}_Y}\mathcal{O}_X.$ That is, the map $\pi^{-1}\mathcal{I}_{V/Y}\otimes_{\pi^{-1}\mathcal{O}_Y}\mathcal{O}_X\rightarrow \mathcal{I}_{V_X/X},$ $i\otimes m\mapsto im$, is an isomorphism. This is always surjective, so this condition is that there are no extra "surprise" relations between the $i$'s and $m$'s (some language borrowed either again Andrew, or from Vakil (24.4.2), I do not know who wrote it first).

Another way of thinking about this is that $\pi:X\rightarrow Y$ is flat if and only if for all closed subschemes $V\hookrightarrow Y$ cut out by $\mathcal{I}_{V/Y},$ the corresponding $V_X\hookrightarrow X$ is cut out exactly by $\pi^*\mathcal{I}_{V/Y}.$ That is, saying that $\pi:X\rightarrow Y$ is flat is equivalent to saying that $X$ sits nicely (or maybe, "flatly"?) over $Y$.