Let be amount invested over years. = rate of return. = tax rate.
You pay taxes upfront. That reduces to . After years this becomes which you can withdraw tax free.
You don’t pay any taxes on . After years the amount becomes . Now when you withdraw it, you pay tax and so the net amount becomes which is same as earlier.
Of course, the catch is the assumption that remains same in both cases.