I am writing a program to calculate approximations to $\pi$ from (a slight reformulation of) John Wallis' formula: $\frac{\pi}{4} = \frac{2\cdot4\cdot4\cdot6\cdot6\cdot8\cdot8\cdots}{3\cdot3\cdot5\cdot5\cdot7\cdot7\cdots}$ and I've done the following: $$\pi = 4\cdot\frac{2\cdot4\cdot4\cdot6\cdot6\cdot8\cdot8\cdots}{3\cdot3\cdot5\cdot5\cdot7\cdot7\cdots}$$ $$\pi = 8\cdot\frac{4\cdot4\cdot6\cdot6\cdot8\cdot8\cdots}{3\cdot3\cdot5\cdot5\cdot7\cdot7\cdots}$$ $$\pi = 8\cdot\left(\frac{4^2}{3^2}\right)\left(\frac{6^2}{5^2}\right)\left(\frac{8^2}{7^2}\right)\cdots$$ $$\pi=8\cdot\prod_{i=2}^{\infty}\left(\frac{2i}{2i-1}\right)^2$$
I have done what I think is correct, simple transformations of the original products. However the product diverges, and this reformulation is wrong. Why?

Note that the limit of an infinite product can be defined via an infinite sum:
$$\prod_{i=1}^\infty a_i:=\exp \sum_{i=1}^\infty \log a_i.$$ And what you are doing in your first step is rearranging the sum in question: the transformation
$$\frac{\color{red}2}{\color{blue}3}\cdot\frac{\color{purple}4}{\color{green}3}\cdots \quad\to\quad \color{red}2\cdot\frac {\color{purple}4}{\color{blue}3}\cdot\frac 4{\color{green}3} \cdots$$
is equivalent to the rearrangement
$$\color{red}{\log 2}-\color{blue}{\log 3}+\color{purple}{\log 4}-\color{green}{\log 3}+\cdots\quad\to\quad \color{red}{\log 2}+\color{purple}{\log 4}-\color{blue}{\log 3}+\log 4-\color{green}{\log 3}+\cdots.$$
But rearranging infinite sums is not always allowed and can change the limit arbitrarily (or even make it diverge) which is explained in this question. This is known as Riemann's rearrangement theorem. It is not hard to see that your corresponding sum is not absolutely convergent, hence the theorem applies.