dihedral group and its generators
Recall that when we say that $G = \langle a, b \, | \, a^2 = b^2 = (ab)^n = 1\rangle$, what we mean is that $G$ is the quotient of the free group $\langle a, b\rangle$ by the normal subgroup $N$ generated by $a^2, b^2, (ab)^n$. Now, let's concretely view $D_n$ as the group of rotations and reflections of the regular $n$-gon which preserve the vertices. I'll assume you're familiar with this group.
We can define a group homomorphism $\varphi :\langle a,b\rangle \to D_n$ by sending $a$ and $b$ to "adjacent" reflections. By this, I simply mean that $\varphi(ab) = \varphi(a)\varphi(b)$ should be a rotation of order $n$. Using our knowledge of $D_n$, it's easy to confirm that $a^2, b^2$ and $(ab)^n$ are in the kernel of $\varphi$. Therefore all of $N$ is contained in the kernel. It follows that there is an induced group homomorphism $$\overline{\varphi}: \langle a, b \, | \, a^2 = b^2 = (ab)^n = 1\rangle \to D_n$$ by the univeral property of the quotient. Moreover, you have shown that the domain of the map has at most $2n$ elements, and by construction $\overline{\varphi}$ is surjective (since $\varphi$ is). Since $|D_n| = 2n$ as well, $\overline{\varphi}$ must be bijective, so we're done.