What is $\left ( \vec{\nabla} \times \vec{A} \right ) \cdot \left ( \vec{\nabla} \times \vec{A} \right )$? I'm trying to rewrite $\left ( \vec{\nabla} \times \vec{A} \right ) \cdot \left ( \vec{\nabla} \times \vec{A} \right )$ in some other way. I tried using Levi-Civita symbol and Kronecker delta, but I'm stuck. Here is what I did:
$$\left ( \vec{\nabla} \times \vec{A} \right ) \cdot \left ( \vec{\nabla} \times \vec{A} \right ) = \left ( \vec{\nabla} \times \vec{A} \right )_i \left (\vec{\nabla} \times \vec{A} \right )_i = \epsilon_{ijk} \frac{\partial A_k}{\partial x_j} \epsilon_{imn} \frac{\partial A_n}{\partial x_m} = \left ( \delta_{jm} \delta_{kn} - \delta_{jn} \delta_{km} \right ) \frac{\partial A_k}{\partial x_j} \frac{\partial A_n}{\partial x_m}$$
$$= \left ( \frac{\partial A_k}{\partial x_m} \right )^{2} - \frac{\partial A_m}{\partial x_j} \frac{\partial A_j}{\partial x_m} = \left ( \frac{\partial A_k}{\partial x_m} \right )^{2} - \frac{\partial A_j}{\partial x_j} \frac{\partial A_m}{\partial x_m} $$
And I'm stuck with both these terms. (I'm sorry for no rigour switching order of partials, but I couldn't come up with anything else). Where I messed up?

Your work so far is correct. The answer given here (by user15546) gives one path to condensing this expression. Let $J$ denote the Jacobian, so that
$$
J_{ij} = \frac{\partial A_i}{\partial x_j}.
$$
Then we can write
$$
\sum_{k,m=1}^3\left ( \frac{\partial A_k}{\partial x_m} \right )^{2} - \sum_{j,m = 1}^3\frac{\partial A_j}{\partial x_j} \frac{\partial A_m}{\partial x_m} = \operatorname{trace}(JJ^T) - \operatorname{trace}(J^2).
$$
We could alternatively derive a similar formula directly, avoiding the index juggling. To start, note the non-zero entries of $J-J^T$ are the components of the curl $\nabla \times A$, with each component appearing twice. Thus,
$$
(\nabla \times A) \cdot (\nabla \times A) =  
\frac 12 \|J - J^T\|_F^2 = 
\frac 12 \operatorname{tr}[(J - J^T)(J^T - J)].
$$
From there, we can expand
$$
\frac 12 \operatorname{tr}[(J - J^T)(J^T - J)] = \\
\frac 12 \left(\operatorname{tr}[JJ^T] - 
\operatorname{tr}[J^2] - \operatorname{tr}[J^TJ^T] + \operatorname{tr}[J^TJ]\right) = \\
\frac 12 \left(2\operatorname{tr}[JJ^T] - 
2\operatorname{tr}[J^2]\right) = \\
\operatorname{tr}[JJ^T] - 
\operatorname{tr}[J^2].
$$
