I need to show that the union of two compact sets is compact. Here is what I tried:
Let $A$ and $B$ be two compact sets. Then for every open cover $\{A_n\}_{n\in I_1}$ and open cover $\{B_m\}_{m\in I_2}$, there exists finite subcovers $\bigcup\limits_{n\in I_1}^p A_n$ such that $A\subseteq\bigcup\limits_{n\in I_1}^p A_n$ and $\bigcup\limits_{b\in I_2}^k B_m$ such that $B\subseteq\bigcup\limits_{b\in I_2}^k B_m$. Then, $A\cup B\subseteq (\bigcup\limits_{n\in I_1}^p A_n)\cup(\bigcup\limits_{b\in I_2}^k B_m)\subseteq(\bigcup\limits_{n\in I_1} A_n) \cup (\bigcup\limits_{b\in I_2} B_m)$ (the union of open covers constructed as an open cover for $A\cup B$). Thus, for ever open cover of $A\cup B,$ there exists a finite subcover, so $A\cup B$ is compact.
I thought that since the open cover I constructed was arbitrary, and so was the finite subcover, then every open cover of $A\cup B$ had a finite subcover. What is wrong with this?
The problem with your logic is as follows:
You are right, in that a finite subcover of $A$ and a finite subcover of $B$, together gives a finite subcover of $A \cup B$.
However, to show $A \cup B$ is compact, you are supposed to start with any arbitrary open cover of $A \cup B$. This was not done: instead, you started with open covers for $A$ and $B$ separately, and used their compactness to produce a finite subcover.
Hence, the answer should be as follows:
Start from definition. Let $\{ U_\alpha\}$ be an open cover of $A \cup B$.
Since $A \cup B \subset \bigcup U_\alpha$, it follows that $A \subset \bigcup U_\alpha$, and similarly, $B \subset \bigcup U_\alpha$. That is, every cover of $A \cup B$ gives a cover of $A$ and a cover of $B$. This is the key step missing from your explanation.
Now, we have finite subcovers for each one, and you can take the union of these subcovers (which remains a subcover of the original cover) to get the result.
So, in short, when we say arbitrary, we have to be careful. It is best that you start out with what is given: In compactness, we are given an open cover of the set, you never gave yourself that, instead you started with open covers for $A$ and $B$ separately, which was not given to you by the definition of $A \cup B$ being compact.
It's all about being careful. And it's absolutely fine to mistakes. It's good you have this clarified now.
As an exercise, try and extend this to a finite union of compact sets. Do you think you can extend this to an infinite union of compact sets?