Compact sets are closed?
I think that what you’re missing is that an open cover of a compact set can cover more than just that set. Let $X$ be a topological space, and let $K$ be a compact subset of $X$. A family $\mathscr{U}$ of open subsets of $X$ is an open cover of $K$ if $K\subseteq\bigcup\mathscr{U}$; it’s not required that $K=\bigcup\mathscr{U}$. You’re right that $\bigcup\mathscr{U}$, being a union of open sets, must be open in $X$, but it needn’t be equal to $K$.
For example, suppose that $X=\Bbb R$ and $K=[0,3]$; the family $\{(-1,2),(1,4)\}$ is an open cover of $[0,3]$: it’s a family of open sets, and $[0,3]\subseteq(-1,2)\cup(1,4)=(-1,4)$. And yes, $(-1,4)$ is certainly open in $\Bbb R$, but $[0,3]$ is not.
Note, by the way, that it’s not actually true that a compact subset of an arbitrary topological space is closed. For example, let $\tau$ be the cofinite topology on $\Bbb Z$: the open sets are $\varnothing$ and the sets whose complements in $\Bbb Z$ are finite. It’s a straightforward exercise to show that every subset of $\Bbb Z$ is compact in this topology, but the only closed sets are the finite ones and $\Bbb Z$ itself. Thus, for example, $\Bbb Z^+$ is a compact subset that isn’t closed.
It is true, however, that compact sets in Hausdorff spaces are closed, though a bit of work is required to establish the result.
For anyone who comes across this question in the future, here is a proof:
Theorem: Compact subsets of metric spaces are closed.
Proof: Let $K$ be a compact subset of a metric space $X$ and to show that $K$ is closed we will show that its complement $K^c$ is open.
Let $p \in K^c$. Now if $q_\alpha \in K$, let $r_\alpha = \frac{1}{2}d(p,q_\alpha)$ and we will denote the neighbourhood of radius $r_\alpha$ around $q_\alpha$ to be $B_{r_\alpha}(q_\alpha) = \{x \in X \mid d(q_\alpha,x) < r_\alpha\}$ and the neighbourhood of radius $r_\alpha$ around $p$ to be $B_{r_\alpha}(p) = \{x \in X \mid d(p,x) < r_\alpha\}$. Then the collection of open sets $\{B_{r_\alpha}(q_\alpha)\}_\alpha$ is an open cover of $K$. As $K$ is compact there exists a finite subcover of $\{B_{r_\alpha}(q_\alpha)\}_\alpha$ such that
$$K \subset B_{r_1}(q_1) \cup \cdots \cup B_{r_n}(q_n) = U.$$
I now make the following claim:
Claim: $(B_{r_1}(p) \cap \cdots \cap B_{r_n}(p)) \cap U = \emptyset$.
Proof: Assume that $x \in (B_{r_1}(p) \cap \cdots \cap B_{r_n}(p)) \cap U$. Then we must have that $x\in B_{r_i}(p)$ for $1 \leq i \leq n$ and $x\in U$. As $x\in U$, then there exists an $i (1 \leq i \leq n)$ such that $x\in B_{r_i}(q_i)$ and, without any loss of generality, we assume $x \in B_{r_1}(q_1)$. In particular, we must also have that $x\in B_{r_1}(p)$. Therefore, by the triangle inequality we have,
$$d(p,q_1) \leq d(p,x) + d(x,q_1) < r_1 + r_1 = d(p,q_1).$$
This however is a contradiction. Therefore, $p \in B_{r_1}(p) \cap \cdots \cap B_{r_n}(p) \subset K^c$ which means that $p$ is an interior point of $K^c$. As $p$ was arbitrary, $K^c$ is open and therefore, $K$ is closed as desired. $_\Box$
Hope this may help someone.
Compact sets need not be closed in a general topological space. For example, consider the set $\{a,b\}$ with the topology $\{\emptyset, \{a\}, \{a,b\}\}$ (this is known as the Sierpinski Two-Point Space). The set $\{a\}$ is compact since it is finite. It is not closed, however, since it is not the complement of an open set.