We have a compact subset $A$ of a metric space $X$ and we want to show that this implies that $A$ is closed.
Let $y \in A$ and $y \in A^c$. For each $y \in A$, we can take open neighbourhoods $U_y$ of $y$ and $V_y$ of $x$ such that $U_y \bigcap V_y = \emptyset$. Because $A$ is compact we only need a finite number of the $U_y$s to cover $A$. So let $U = \bigcup_{i=1}^N U_i$ and $V = \bigcap_{i=1}^N V_i$. Then $U$ and $V$ are open and $U \bigcap V = \emptyset$.
Now $x \in V \subseteq A^c$ and as $x$ is arbitrary $A^c$ is open. Hence $A$ is closed.
What I don't get is how does the compactness assumption help us here? Why can't we just take an infinite number of $U_y$s that cover $A$? That is let $U = \bigcup_{i \in I} U_y$ and $V = \bigcap_{i \in I} V_y$ where $I$ is an infinite index set.
Then we can still say $x \in V \subseteq A^c$ and as $x$ is arbitrary $A^c$ is open. Hence $A$ is closed?
The following is not so much an answer to the question, as a commentary on the unnecessary use
of the axiom of choice in the proof given by the author of the question. I am doing this because
this kind of abuse of AC is typical.
We can avoid using AC in the following way.
Suppose we have a compact subset $A$ of a Hausdorff space $X$ (every metric space has a Hausdorff topology); we shall prove that $A$ is closed. Let $x\in X\setminus A$. We claim that some open neighborhood of $x$ is contained in $X\setminus A$; this will prove that $A$ is closed.
Let $I$ be the set of all pairs of open sets $(U,V)$ where $x\in U$ and $U\cap V=\varnothing$. For each $i=(U,V)\in I$ we let $N_i:=U$ and $W_i:=V$. If a point $y\in X$ is different from $x$, then
there exists $i=(U,V)\in I$ such that $y\in V=W_i$, because $X$ is a Hausdorff space.
Therefore $\bigcup_{i\in I}W_i=X\setminus\{x\}$. In particular, $A$ is contained in the union $\bigcup_{i\in I}W_i$.
Since $A$ is compact, it is contained in the union $\bigcup_{k\in K}W_k$ for some finite subset $K$ of $I$.
Then the point $x$ has an open neighborhood $\bigcap_{k\in K}N_k$ that is disjoint with the open
neighborhood $\bigcup_{k\in K}W_k$ of the set $A$, and hence is disjoint with the set $A$ itself.
Our claim is proved.