If $\frac{z-a}{z+a},a\in \mathbb{R}$ is a purely imaginary number and $|z|=2$, then a value of a is ___. (JEE Main 2019)
For a purely imaginary number $w$, we must have $w+\bar{w}=0$, giving us $a=2$. (This solution is standard substitution and simplification, resulting in a quadratic).
I tried it using a different method(below): $$\frac{z-a}{z+a}\times\frac{\bar{z}-a}{\bar{z}-a}=\frac{z\bar{z}-az-a\bar{z}+a^2}{z\bar{z}-a^2}=\frac{z\bar{z}-az-a\bar{z}+a^2}{|z|^2-a^2}=\frac{z\bar{z}-az-a\bar{z}+a^2}{4-a^2}$$ where in the last step we substituted $z\bar{z}=|z|^2=4, z+\bar{z}=0$$
The denominator of this expression (from the other, valid solution is zero), and hence the expression is not defined.
What was the mistake and at what step was it made?
You expanded $(z + a)(\bar{z} - a)$ as $z\bar{z} - a^2$, when the correct expression is $z\bar{z} + a\bar{z} - az - a^2$. As the comments point out, you also wrote that $z + \bar{z} = 0$, which you can't assume, since $z$ is not necessarily purely imaginary.
In general, for problems like this, pick a value of $z$ (any value) that fits your hypothesis, and plug it in at each step; you'll see where the error happens quite easily.