Let $\pi:X\to Y$ be a conitionuis surjective map between two Hausdorff sapces $X,Y$. Suppose that for each $y\in Y$, the reimage $\pi^{-1}(y)$ is compact.
Question
Can we say that for each compact subset $B\subset Y$, the preimage $\pi^{-1}(B)$ is also compact?
No.
Consider $\operatorname{Id}\colon (\Bbb{R}, \tau_\text{discrete}) \to (\Bbb{R}, \tau_\text{euclidean})$ defined by $$\operatorname{Id}(x) =x$$
$\operatorname{Id}$ is continuous onto (in fact bijective) map.
$\operatorname{Id}^{-1}(\{x\})=\{x\} $ is compact.
$\operatorname{Id}^{-1}([0, 1]) =[0, 1]$ is not compact.
Note :
Any map defined on a discrete space is continuous.
A subset of a euclidean space is compact iff closed and bounded.
A subset of a discrete space is compact iff it is finite.