A dominant map of affine varieties corresponds to an inclusion of rings $R \subseteq S$, where $S$ is integral over $R$. You can identify $X, Y$ with the maximal spectra of $S, R$, and $f: X \rightarrow Y$ is the contraction map $\mathfrak n \mapsto \mathfrak n \cap R$.
A closed subset $Z$ of $X$ corresponds to a radical ideal $J$ of $S$. Specifically, $J$ is the intersection of all the maximal ideals in $Z$. Finite morphisms of varieties are closed, so $f(Z)$ corresponds to a radical ideal $I$ of $R$. One can identify $Z$ with the maximal spectrum of $S/J$, and $f(Z)$ with the maximal spectrum of $R/I$.
Concretely, $f(Z)$ is the set of all $\mathfrak n \cap R : \mathfrak n \in Z$, and so $I$ is equal to $$\bigcap\limits_{\mathfrak m \in f(Z)} \mathfrak m = \bigcap\limits_{\mathfrak n \in Z} (\mathfrak n \cap R) = R \cap \bigcap\limits_{\mathfrak n \in Z} \mathfrak n = R \cap J$$
The composition $Z \rightarrow X \rightarrow f(Z)$ then corresponds to the ring homomorphism $\pi: R/I \rightarrow S/J$. This is well defined and injective. Since $S$ is integral over $R$, $S/J$ is integral over the image of $R/I$, hence $Z \rightarrow f(Z)$ is a finite, dominant morphism of varieties.