[proofplan]
We prove two statements. Part (1): if $X$ is compact and $Y$ is closed, then $Y$ is compact. The proof augments any open cover of $Y$ with the open complement $X \setminus Y$ to get an open cover of $X$, extracts a finite subcover by compactness, and discards $X \setminus Y$. Part (2): if $X$ is Hausdorff and $Y$ is compact, then $Y$ is closed. The proof shows $X \setminus Y$ is open by constructing, for each $x \in X \setminus Y$, an open neighbourhood of $x$ disjoint from $Y$ using the Hausdorff property and compactness of $Y$.
[/proofplan]
[step:Prove closed subsets of compact spaces are compact by augmenting the cover]
Let $X$ be compact, $Y \subseteq X$ closed, and $\{U_i\}_{i \in I}$ an open cover of $Y$ in the subspace topology. Write $U_i = Y \cap W_i$ for [open sets](/page/Open%20Set) $W_i \subseteq X$. Since $Y$ is closed, $X \setminus Y$ is open in $X$. The collection $\{W_i\}_{i \in I} \cup \{X \setminus Y\}$ is an open cover of $X$: every point of $Y$ lies in some $W_i$, and every point of $X \setminus Y$ lies in $X \setminus Y$.
By compactness of $X$, there exist $i_1, \ldots, i_k \in I$ such that $X = W_{i_1} \cup \cdots \cup W_{i_k} \cup (X \setminus Y)$. Intersecting with $Y$: $Y \subseteq W_{i_1} \cup \cdots \cup W_{i_k}$, so $Y = U_{i_1} \cup \cdots \cup U_{i_k}$. This is a finite subcover of the original cover of $Y$.
[guided]
The idea is to "promote" an open cover of $Y$ to an open cover of $X$, use compactness of $X$ to get a finite subcover, then "restrict" back to $Y$.
Given an open cover $\{U_i\}_{i \in I}$ of $Y$ (open in the subspace topology), write $U_i = Y \cap W_i$ with $W_i$ open in $X$. The sets $\{W_i\}$ cover $Y$ but not necessarily the rest of $X$.
To cover all of $X$, we add the single open set $X \setminus Y$. This set is open precisely because $Y$ is closed --- this is the one place the closedness hypothesis is used. Now $\{W_i\}_{i \in I} \cup \{X \setminus Y\}$ is an open cover of $X$: every point of $Y$ lies in some $W_i$, and every point of $X \setminus Y$ lies in $X \setminus Y$.
Compactness of $X$ gives a finite subcover: $X = W_{i_1} \cup \cdots \cup W_{i_k} \cup (X \setminus Y)$ for some $i_1, \ldots, i_k \in I$. After discarding $X \setminus Y$ (which contributes nothing to covering $Y$), the remaining sets still cover $Y$: $Y \subseteq W_{i_1} \cup \cdots \cup W_{i_k}$.
Intersecting with $Y$ recovers the original subspace-open sets: $Y = (Y \cap W_{i_1}) \cup \cdots \cup (Y \cap W_{i_k}) = U_{i_1} \cup \cdots \cup U_{i_k}$. This is a finite subcover of the original cover of $Y$.
[/guided]
[/step]
[step:Prove compact subsets of Hausdorff spaces are closed by showing the complement is open]
Let $X$ be Hausdorff, $Y \subseteq X$ compact. We show $X \setminus Y$ is open. Fix $x \in X \setminus Y$. For each $y \in Y$, the Hausdorff property provides disjoint open sets $U_y \ni x$ and $V_y \ni y$ with $U_y \cap V_y = \varnothing$.
The collection $\{V_y \cap Y\}_{y \in Y}$ is an open cover of $Y$ in the subspace topology. By compactness of $Y$, finitely many suffice: there exist $y_1, \ldots, y_k \in Y$ with $Y \subseteq V_{y_1} \cup \cdots \cup V_{y_k}$.
Define $U = U_{y_1} \cap \cdots \cap U_{y_k}$. This is a finite intersection of open sets, hence open, and $x \in U$ (since $x \in U_{y_j}$ for every $j$).
[claim:$U$ is disjoint from $Y$]
$U \cap Y = \varnothing$.
[/claim]
[proof]
Suppose $z \in U \cap Y$. Since $Y \subseteq V_{y_1} \cup \cdots \cup V_{y_k}$, there exists $j \in \{1, \ldots, k\}$ with $z \in V_{y_j}$. But $z \in U \subseteq U_{y_j}$, so $z \in U_{y_j} \cap V_{y_j}$. This contradicts $U_{y_j} \cap V_{y_j} = \varnothing$.
[/proof]
Therefore $U \subseteq X \setminus Y$ is an open neighbourhood of $x$ contained in $X \setminus Y$. Since $x \in X \setminus Y$ was arbitrary, $X \setminus Y$ is open, so $Y$ is [closed](/page/Closed%20Set).
[guided]
The strategy is to show that every point $x \in X \setminus Y$ has an open neighbourhood disjoint from $Y$. The Hausdorff property separates $x$ from each individual point $y \in Y$ by disjoint open sets $U_y \ni x$ and $V_y \ni y$ with $U_y \cap V_y = \varnothing$.
The problem is that the neighbourhood $U_y$ depends on $y$: we get a different open set around $x$ for each $y \in Y$, and the intersection $\bigcap_{y \in Y} U_y$ over all $y \in Y$ could fail to be open (arbitrary intersections of open sets need not be open).
This is where compactness of $Y$ enters. The sets $\{V_y \cap Y\}_{y \in Y}$ form an open cover of $Y$ in the subspace topology. By compactness, finitely many suffice: $Y \subseteq V_{y_1} \cup \cdots \cup V_{y_k}$.
Now define $U = U_{y_1} \cap \cdots \cap U_{y_k}$. This is a finite intersection of open sets, hence open. It contains $x$ (since $x \in U_{y_j}$ for every $j$). And it is disjoint from $Y$: any $z \in Y$ lies in some $V_{y_j}$ (by the finite subcover), and $U \subseteq U_{y_j}$ is disjoint from $V_{y_j}$ (by the Hausdorff separation), so $z \notin U$.
Therefore $U \subseteq X \setminus Y$ is an open neighbourhood of $x$ in $X \setminus Y$. Without compactness of $Y$, the finite intersection step would fail --- indeed, a non-compact subset of a Hausdorff space need not be closed (e.g., $(0,1)$ in $\mathbb{R}$).
[/guided]
[/step]