If $A_n$ are compact in $\mathbb R$ for $n\in\mathbb N$, then $\bigcup_{n=1}^\infty A_n$ is compact.
I seem to be able to prove the statement by proving the base case that the union of 2 compact sets is compact and then using induction on n to prove the general case. But there are obvious counter-examples such as letting $A_n$ be $[\frac{1}{n},1]$, then the countable union would be $(0,1]$, which is not compact. So I am confused whether the statement is true, and what is wrong with the induction proof.
Induction proves the statement for any finite number, not a countably infinite number. The reason it only shows it for finite numbers is that induction proves that $P(k)$ is true, then so is $P(k+1)$.
Also note that if you find a counterexample to a statement, then the statement can't be true (in particular, you found a counterexample to your statement, so it definitely couldn't be correct).