I have this doubt in vector analysis I need help with.
I know that cross product of a vector with itself is a null vector ($\vec a\times \vec a=\vec 0)$ as both point the same direction. Now consider this :
$$\vec i\times(\vec a\times \vec i) = (\vec i \cdot \vec i)\vec a-(\vec i\cdot \vec a)\vec i=\vec a-(\vec i\cdot \vec a)\vec i.$$
But should this not be simply zero using the fact that $\vec i\times \vec i=0$?
As Daniel Fischer points out, the cross product is not associative nor commutative, so you can't (legitimately) rearrange the expression $\vec{i}\times (\vec{a}\times\vec{i})$ to get the expression $\vec{i}\times\vec{i}$.
Here's a geometric way to see that the expression $\vec{i}\times(\vec{a}\times\vec{i})$ is not necessarily zero. Suppose $\vec{a}$ is not parallel to $\vec{i}$ (i.e. they are not scalar multiples of one another), then $\vec{a}\times\vec{i}$ is a non-zero vector orthogonal to both $\vec{a}$ and $\vec{i}$; in particular, $\vec{a}\times\vec{i}$ is not parallel to $\vec{i}$. Then $\vec{i}\times(\vec{a}\times\vec{i})$ is a non-zero vector orthogonal to both $\vec{i}$ and $\vec{a}\times\vec{i}$. For example, if $\vec{i}$ is the unit vector in the direction of the positive $x$-axis, and $\vec{j}$ is the unit vector in the direction of the positive $y$-axis, then $\vec{j}\times\vec{i} = -\vec{k}$, where $\vec{k}$ is the unit vector in the direction of the positive $z$-axis. Then $$\vec{i}\times(\vec{j}\times\vec{i}) = \vec{i}\times(-\vec{k}) = -\vec{i}\times\vec{k} = -(-\vec{j}) = \vec{j} \neq \vec{0}.$$