We have more generally the following fact.
Let $X$ be compact and $Y$ Hausdorff. If $f: X \to Y$ is continuous and bijective, then $f$ is a homeomorphism.
We can prove this by showing that $f$ is a closed map, making it a homeomorphism. Let $C$ be an arbitrary closed set in $X$. Since $X$ is compact, then $C$ is compact [1]. Since $f$ is continuous, the image $f (C)$ is compact in $Y$ [2]. Since $f (C)$ is a compact subspace of a Hausdorff space, then $f (C)$ is closed [3], as desired.
It is easy to see how your statement follows. Since $X, Y$ are both compact metric spaces, then $X$ is compact, and $Y$, being a metric space, is Hausdorff [4]. The fact above applies to show that any continuous and bijective $f: X \to Y$ is a homeomorphism.
Proof of some basic facts:
[1] Closed subspace of compact space is compact.
Let $X$ be compact and $A \subseteq X$ be closed. Suppose $\{ U_\alpha \}$ is a collection of open sets of $X$ that covers $A$. Consider the collection $\{ U_\alpha \} \cup \{ X - A \}$, which is an open cover of $X$. Since $X$ is compact, there is a finite subcover $\{ U_1, \dots, U_N \}$. The collection $\{ U_1, \dots, U_N \} - \{ X - A \} \subseteq \{ U_\alpha \}$ is finite and covers $A$.
[2] Continuous image of compact set is compact.
Suppose $A$ is compact, and let $f$ be continuous. Suppose that $\{ V_\alpha \}$ is an open cover of $f (A)$. Since $f$ is continuous, the collection $\{ f^{-1} (V_\alpha) \}$ is an open cover of $A$. Since $A$ is compact, there is a finite collection $\{ f^{-1} (V_1), \dots, f^{-1} (V_N) \} \subseteq \{ f^{-1} (V_\alpha) \}$ that covers $A$. The collection $\{ V_1, \dots, V_N \} \subseteq \{ V_\alpha \}$ is therefore a finite open cover of $f (A)$.
[3] Compact subspace of Hausdorff space is closed.
Suppose $X$ is Hausdorff, and let $A \subseteq X$ be compact. We show that $X - A$ is open. Let $x \notin A$. For each point $y \in A$, we have that $x \ne y$, so that there exist disjoint neighborhoods $U_y$ of $x$ and and $V_y$ of $y$, since $X$ is Hausdorff. The collection $\{ V_y \}$ is an open cover of $A$; since $A$ is compact, there is a finite collection $\{ V_{y_1}, \dots, V_{y_N} \} \subseteq \{
V_y \}$ that covers $A$. The neighborhood $U = \bigcap_{n = 1}^N U_{y_n}$ of $x$ is disjoint from $A$.
[4] Metric space is Hausdorff.
Let $X$ be a metric space, and $x \ne y \in X$. Therefore, $d (x, y) = \delta > 0$. Consider the neighborhoods $U = B_d \left( x, \frac{1}{2} \delta \right)$ of $x$ and $V = B_d \left( y, \frac{1}{2} \delta \right)$ of $y$. They are disjoint: if $z \in U \cap V$, then $d (z, y), d (z, x) < \frac{1}{2} \delta \implies d (x, y) \le d (x, z) + d (z, y) < \delta$, which is a contradiction.