$ G/H \cong K $ and $ G/K \cong H\implies G \cong H \times K $

I think I have a counterexample. Let $D = \langle a,b \mid b^2=(ab)^2 = 1 \rangle$ be the infinite dihedral group, and let $X = \langle a_1,b_1 \rangle \times \langle a_1,b_2 \rangle$ be the direct product of two copies of $D$.

Now let $G = \langle a_1^2,b_1,a_2^2,b_2,a_1a_2 \rangle \le X$, and note that $|X:G| = 2$.

Let $H = \langle a_1^2,b_1 \rangle$ and $K = \langle a_2^2,b_2 \rangle$. Then $H \cong K \cong D$, and $H \times K \le G$ with $|G:(H \times K)| = 2$.

Now $G/H$ is generated by the images in $H$ of $a_1a_2$, $a_2^2$ and $b_2$, but $(a_1a_2)^2H = a_2^2H$ and $(a_1a_2b_2)^2H = H$, so $G/H \cong D \cong K$ and similarly $G/K \cong H$.

Now, since $[b_1,a_1a_2] = [b_1,a_1] = a_1^2$ and $[b_2,a_1a_2] = a_2^2$, we see that $G/[G,G]$ is a $3$-generator group (of order 8) generated by the images of $b_2$, $b_2$ and $a_1a_2$.

But the abelanization of $H \times K$ is a $4$-generator group of order $16$, so $G \not\cong H \times K$.