Number of ways to color cubes a $4\times4\times4$ cube with red s.t. in every $1\times1\times4$ cube there is only one red $1\times1\times1$ cube? How many ways are there to color cubes a $4\times4\times4$ cube with red that in every $1\times1\times4$ cube there is only one red $1\times1\times1$ cube
My attempt:First I colored the first $4\times4$ layer there are $4!$ ways to do that .Consider that the first layer is like the picture below:

But in the second layer counting becomes too hard and also we have to count the ways of coloring the third and forth layer.I need an easier way for solving this.
 A: My impression is that these are equivalent to $4 \times 4$ Latin squares.  We define a Latin square $L=(l_{ij})$ by $l_{ij}=k$ whenever cell $(i,j,k)$ is red.
Clashes with two red cells in a $1 \times 4 \times 1$, $4 \times 1 \times 1$, and $1 \times 1 \times 4$ submatrices will correspond to either two identical symbols in the same row, two identical symbols in the same column, or a cell containing two distinct symbols, respectively.
If you want to enumerate them, this is indeed a difficult problem in general, but for the $4 \times 4$ special case if you exploit a few symmetries, it's not too bad.  Specifically, it's substantially easier to count reduced Latin squares $R_n$, i.e., those with the first row and column in natural order, since the number of Latin squares $L_n=n!(n-1)!R_n$.
I.e., $R_n$ is the number of ways of filling in:
$$
\begin{bmatrix}
1 & 2 & 3 & 4 \\
2 & ? & ? & ? \\
3 & ? & ? & ? \\
4 & ? & ? & ? \\
\end{bmatrix}
$$
using the symbols $\{1,2,3,4\}$ such that no row nor column contains a repeated symbol.

If the restriction is indeed only on $1 \times 1 \times 4$ submatrices, then we can choose one red cell in each $1 \times 1 \times 4$ submatrix (or choose none, if that is permitted), which can be done independently, and thus the possibilities are easy to enumerate. 
A: 
Here we count all valid configurations and show they sum up to
  $$6\cdot4!\cdot 4=576$$

In the following we use cell to denote  a $1\times1\times1$ cube.
If we project all four layers to the bottom layer, then each of the $4\cdot 4=16$ cells is red colored. So, we have to find all valid configurations of a $4\times 4\times 4$ cube with $16$ red cells.

Bottom layer:
We observe, already stated by OP, there are $$4\cdot 3\cdot 2 \cdot 1=4!$$ valid configurations to place $4$ red cells in the bottom layer. Each row and each column of the cell contains precisely one red cell.

Encoding the layers:
Each layer consists of $4$ rows and $4$ columns. We use a $4$-tupel $(a,b,c,d)$ to encode the positions of the red cells within a layer. The $i$-th coordinate corresponds to the $i$-th row and the entry gives the number of the column with the red cell. The example bottom layer given by OP is therefore encoded as
\begin{align*}
(1,2,3,4)
\end{align*}
For example the third component describes the third row of the bottom layer and the entry of this row is $3$ since the placement of the red cell  is in the third column.

Grouping the bottom layers:
We now classify the bottom layers by selecting those with a red cell at the top-left corner. These are the configurations which are encoded as
  \begin{align*}
(1,b,c,d)
\end{align*}
  meaning the cell in the first column of the first row is a red cell. Since $b,c,d$ permute $2,3$ and $4$ there are precisely 
  \begin{align*}
3!
\end{align*}
  configurations of this type. We can now classify the $4!=24$ valid configurations of the bottom layer by taking a layer with $(1,b,c,d)$ as representative of a four element group which is obtained by shift-rotate each red cell in a row by one.

The red cells in the example layer of OP which is encoded by $(1,2,3,4)$ can be shifted by $1$ to the right and we obtain the bottom layer
\begin{align*}
(1,2,3,4)\quad\longrightarrow(2,3,4,1)
\end{align*}
We can do this shift operation three times and obtain the four bottom layers


Observation: The operation shift-rotate by one  to each of the $6$ bottom layers $(1,b,c,d)$ partitions the $24$ bottom layers by declaring $(1,b,c,d)$ as representative of a four element group and by associating all bottom layers shift-rotated by one to it.

Note: If we consider the left-most layer $(1,2,3,4)$ we denote the columns from left to right with $(c_1,c_2,c_3,c_4)$. A shift-rotate operation moves all columns by one to the right and the right-most column is placed at the first position to the left.
\begin{align*}
(c_1,c_2,c_3,c_4)\quad\rightarrow\quad (c_4,c_1,c_2,c_3)
\end{align*}
The four layers are obtained by consecutively applying a shift-rotate by one operation. We obtain
\begin{align*}
(c_1,c_2,c_3,c_4)\quad\rightarrow\quad(c_4,c_1,c_2,c_3)\quad\rightarrow\quad
(c_3,c_4,c_1,c_2)\quad\rightarrow\quad(c_2,c_3,c_4,c_1)\\
\end{align*}
and as we can see in the picture above the red cells move correspondingly encoded as
\begin{align*}
(1,2,3,4)\quad\rightarrow\quad(2,3,4,1)\quad\rightarrow\quad
(3,4,1,2)\quad\rightarrow\quad(4,1,2,3)\\
\end{align*}

Upper layers:
Note, when looking at the four layers above, there are no two equal numbers in the same row or in the same column. So, this grouping with shift-rotation has the nice effect that the four layers can also be stacked and give a valid configuration with $4$ layers and $16$ red cells. 
Note, we can shuffle these four layers and we always obtain a valid configuration. If we denote the four layers with $(L_1,L_2,L_3,L_4)$, we can permute the four layers in $$4!=24$$ different ways
  \begin{align*}
&(L_1,L_2,L_3,L_4)\\
&(L_1,L_2,L_4,L_3)\\
&(L_1,L_3,L_2,L_4)\\
&\quad\quad\ \ \ldots\\
&(L_4,L_3,L_2,L_1)\\
\end{align*}
  and each of these stacked layers is a valid configuration.

It follows, since there are $6$ representatives $(1,b,c,d)$ of a group of four layers obtained by a shift-rotate by one operation, which can be stacked in $4!$ different ways, we obtain 
\begin{align*}
6\cdot 4!\tag{1}
\end{align*}
different valid configurations.

Three more with $(1,2,3,4)$:
Checking for valid, stackable configurations starting with $(1,2,3,4)$ shows there are precisely three more corresponding to the figures below. Each line shows the four layers of a stackable configuration.





It is not too cumbersome to find these configurations, since in the first row the cells have a fixed position and we simply have to check that there are no to equal cells in the same row or in the same column, which strongly reduces possible configurations.

Due to symmetry we find for each of the six configurations with a red cell at the bottom-left corner such groups of figures, so that we finally conclude:

Conclusion: According to the intermediate result (1) and the four different shift-rotate operations, we obtain $6$ representatives $(1,b,c,d)$ of the $24$ bottom layers. Each representative can be used together with a shift-rotate operation from (3) to build $4!=24$ valid $4\times 4\times 4$ cubes with $16$ red colored cells. Since there are four different shift-rotate operations, we finally obtain
  \begin{align*}
6\cdot 4!\cdot 4=576
\end{align*}
  valid configurations.

Note: Counting $A(3)$, all $3\times3\times3$ cubes with $9$ red cells of the wanted type, gives $A(3)=12$ valid configurations. In fact the sequence $A(n)$, starting with $1,2,12,\color{blue}{576}, 161280,\ldots$ is archived as A002860 and counts the number of latin squares of order $n$ in accordance with the answer of @RebeccaJStones.
A: Consider an internal diagonal of the $4\times 4\times 4$ cube. There are $4$ to choose from. Select one and color all the cubes red. Then every $1\times 1\times 4$ slice in the $4\times 4\times 4$ cube will have exactly one red $1\times 1\times 1$ cube.
