Let $K\subseteq M$ be a compact subset of a real $m$-dimensional manifold ($m\geq 1$). Let $\{U_i\}_i$ be an atlas of $M$. I am trying to show that then $K$ can be written as $K=K_1\cup\ldots \cup K_n$ for some $n$, where each $K_j$ is compact, and for each $j=1,\ldots,n$ it holds that $K_j\subseteq U_i$ for some $i$.
My thoughts: Since $K$ is compact and $\{U_i\}_i$ is a cover of $K$, we find $U_1,\ldots,U_n$ such that $K\subseteq\cup_{j=1,\ldots,n}U_j$. Set $K_j=\operatorname{cl}(K\cap U_j)$. By Heine-Borel these $K_j$ are all compact and their union is $K$ by construction.
Is this proof correct?
It might be worth noting that you do not need any countability assumptions to prove this - the Hausdorff property is enough, and in fact we don't even need $\{U_i\}$ to be an atlas or $M$ to even be a manifold - an arbitrary open covering of $K$ will suffice, provided $M$ is a Hausdorff topological space and $K\subseteq M$ is compact.
Observe that for each $x\in K$, if $x\in U_i$ then there is a neighborhood $V_x\subseteq U_i$ for which $\operatorname{cl}(K\cap V_x)\subseteq U_i$.
To prove this, observe that otherwise, there is some $x\in U_i$ for which the sets $C_V:=\operatorname{cl}(K\cap V)\backslash U_i$ are nonempty for every neighborhood $V\subseteq U_i$ of $x$, and are closed subsets of $K$.
Moreover, since $$\bigcap_\alpha C_{V_\alpha}= \left(\bigcap_{\alpha} \operatorname{cl}(K\cap V_\alpha)\right) \backslash U_i \supseteq \operatorname{cl}\left(K\cap \bigcap_\alpha V_\alpha\right)\backslash U_i\neq \emptyset$$ for any finite collection of such neighborhoods $V_\alpha$ of $x$, the family of all such sets $C_V$ for all neighborhoods of $x$ in $U_i$ has the finite intersection property, and hence by compactness has nonempty intersection. But then there is a point $y\in \bigcap_V C_V\subseteq K\backslash U_i\not\ni x$, hence $y\neq x$, and yet $y$ lies in the closure of every neighborhood of $x$, contradicting the Hausdorff property.
You can now apply your original argument to the neighborhoods $V_x$.