Compactness of $Y$ implies compactness of $X$

Claim: With $p$ as above we have:

$$ X \space compact \iff Y \space compact$$

Proof:

Since $p: X \to Y$ is a continuous surjection we obtain the "$\implies$" direction.

For the converse pick $U_{\alpha}$ an open cover of $X$. Since $p^{-1}(\{y\})$ is compact and is covered by $\cup_{\alpha} U_{\alpha}$ there is a finite subcover covering $p^{-1}(\{y\})$. We get $p^{-1}(\{y\}) \subset U_{\alpha (y)}:=\cup_{1 \leq i \leq m}U_{\alpha_i}$. Because $p$ is closed we know that $F_{\alpha (y)}:=p(X\setminus U_{\alpha (y)})$ is closed aswell. Therefore $W_{\alpha (y)}:=Y\setminus F_{\alpha (y)}$ is open and $$p^{-1}(W_{\alpha (y)})=p^{-1}(Y \setminus F_{\alpha (y)})=X \setminus p^{-1}(F_{\alpha (y)})=X\setminus p^{-1}(p(X \setminus U_{\alpha (y)})) \subset U_{\alpha (y)}$$

where in the last step we used $A \subset f^{-1}(f(A))$ because there might be more elements mapping into $A$ (I leave it to you to figure this out, maybe draw a picture rather than prove it rigorously).

This actually proves the hint.

Now observe that $$\cup_{y \in Y} W_{\alpha (y)}=\cup_{y \in Y}Y \setminus p(X\setminus U_{\alpha(y)})=Y\setminus \cap_{y \in Y}p(X \setminus U_{\alpha(y)}) \supset Y\setminus p(\cap_{y \in Y}X\setminus U_{\alpha(y)})=Y \setminus p(X\setminus \cup_{y\in Y}U_{\alpha(y)}) \supset Y$$

where in the last step we used the fact that $p^{-1}(\{y\})\subset U_{\alpha(y)}$. (To see the set-theoretic argument of the inclusion draw a picture).

Finally use the compactness of $Y$ to extract a finite subcover $\{W_{\alpha(y)_j}\}_{1\leq j \leq n}$ of $Y$. We then obtain:

$$X=\cup_{1 \le j \le n}p^{-1}(W_{\alpha(y)_j}) \subset \cup_{1 \le j \le n} U_{\alpha(y)_j}$$

Since the $U_{\alpha(y)}$ are just finite unions of sets in the open cover $U_{\alpha}$ we were able to finde a finite subcover of the original (arbitrary) cover. This gives us the compactness of $X$ and concludes the proof.