Suppose $C \subseteq Y$ is compact.
Let $\mathcal{U}$ be an open cover for $f^{-1}[C]$ by open sets of $X$, so that
$$f^{-1}[C] \subseteq \bigcup \mathcal{U}$$
For each $y \in C$ we know that $f^{-1}[\{y\}]$ is compact by assumption and as $f^{-1}[\{y\}]\subseteq f^{-1}[C]$, this compact set is also covered by $\mathcal{U}$. So for each $y \in C$ we have a finite subset $\mathcal{U}_y$ of $\mathcal{U}$ such that:
$$f^{-1}[\{y\}] \subseteq U_y := \bigcup \mathcal{U}_y \tag{1}$$
Next we define $$O_y = Y\setminus f[X\setminus U_y]\tag{2}$$
and note that $$\forall y \in C: y \in O_y\tag{3}$$
and $$\forall y \in C: f^{-1}[O_y] \subseteq U_y\tag{4}$$
Proof of (3): suppose that $y \notin O_y$. This means by def. $(2)$ that $y \in f[X\setminus U_y]$, so there is some $x \in X\setminus U_y$ with $f(x)=y$. But then this $x \in f^{-1}[\{y\}]$ but $x \notin U_y$, contradicting $(1)$. This shows $(3)$.
Proof of (4): let $x \in f^{-1}[O_y]$ be arbitary. If $x \notin U_y$ we'd have that $f(x) \in f[X\setminus U_y]$ so $f(x) \notin O_y$ contradicting that $x \in f^{-1}[O_y]$. So $x \in U_y$ and the inclusion $(4)$ has been shown.
So $\{O_y: y \in C\}$ is an open cover of $C$ and, as $C$ is compact, there are finitely many $y_1, y_2, \ldots y_n \in C$ such that $C \subseteq \bigcup_{i=1}^n O_{y_i}$
Then (using $(4)$ as well): $$f^{-1}[C] \subseteq f^{-1}[\bigcup_{i=1}^n O_{y_i}] = \bigcup_{i=1}^n f^{-1}[O_{y_i}] \subseteq \bigcup_{i=1}^n \bigcup \mathcal{U}_{y_i}\tag{5}$$
and $(5)$ shows that $\bigcup_{i=1}^n \mathcal{U}_{y_i}$ is a finite subcover of $\mathcal{U}$ (as it is a finite union of finite sets), as we had to find. So $f^{-1}[C]$ is compact.
Note that continuity of $f$ is never used, just onto-ness and closedness of $f$ and its compact fibres.