We want to show that $|A\cup C|=|B\cup D|$. Since $|A|=|B|$ and $|C|=|D|$, there are bijections $g:A\to B$ and $h:C\to D$.
Define $f:A\cup C\to B\cup D$ as follows:
$$ f(x)= \begin{cases} g(x)&\text{if}&x\in A\\\ h(x)&\text{if}&x\in C \end{cases}. $$
Then, $f$ is a bijection since $A\cap C=B\cap D=\emptyset$.