$\def\p{\partial}$
First of all you are correct: the quantity $\left(\frac{\p z}{\p W}\right)$
is definitely a third-order tensor. The field of machine learning is full of folks (even professors) who use atrocious mathematics.
Second (as you have discovered), it is very difficult to apply the chain rule in matrix calculus because it requires intermediate quantities which are third and fourth order tensors. No one cares about these intermediate quantities, because the final result is always a scalar, vector, or matrix.
A simpler approach is to use differentials, because the differential of a matrix has the same dimensionality as the matrix, and it obeys all of the rules of matrix algebra.
One piece of notation that makes things less error prone (especially transpose errors) is the trace/Frobenius product (denoted by a colon) between two equally-sized matrices, i.e.
$$A:B = {\rm tr}(A^TB) = \sum_i\sum_j A_{ij}B_{ij}$$
The properties of the trace allow such products to be rearranged
in many equivalent ways, e.g.
$$\eqalign{
A:B &= B:A = B^T:A^T \\
CA:B &= A:C^TB = C:BA^T \\
}$$
This product also works for vectors (simply think of them as rectangular matrices)
$$a:b = {\rm tr}(a^Tb) = a^Tb \\$$
Assume we have a quadratic loss function
$$L = \tfrac 12 (z-\hat z):(z-\hat z)$$
and wish to calculate its gradient with respect to $W$.
Start by calculating the differential
$$\eqalign{
dL &= \tfrac 12d(z-\hat z):(z-\hat z)+\tfrac 12(z-\hat z):d(z-\hat z) \\
&= (z-\hat z):d(z-\hat z) \\
&= (z-\hat z):dz \\
&= (z-\hat z):dW\,a \\
&= (z-\hat z)a^T:dW \\
}$$
Now the gradient is easily identified as
$$\eqalign{
\frac{\p L}{\p W} &= (z-\hat z)a^T \\
}$$
But now you understand the origin of the $a^T$ term. It comes from rearranging a Frobenius product. It is definitely not equal to $\left(\frac{\p z}{\p W}\right)^T$
Notice that this gradient has the same dimensions as the $W$ matrix, exactly as you anticipated. This is due to the presence of the $dW$ factor on the RHS of the Frobenius product, which has the same dimensions as $W$.
The standard text for this stuff is Matrix Differential Calculus
by Magnus & Neudecker.
rearranging a Frobenius productto get the expression for $\frac{dL}{dW}$? can you simply divide by $dW$? – ihadanny Nov 21 '20 at 19:53