Given matrices $A \in \Bbb R^{m \times q}$, $B \in \Bbb R^{m\times n}$, $C \in \Bbb R^{p\times q}$,
$$ \min_{X \in \Bbb R^{n \times p}} \, \| A - B X C \|_F^2 $$
Similar questions have been answered
Minimize $ \|A-BXC \|_F$ subject to $\mbox{rank} (X) \leq r$
How to do least squares fitting with matrix product of 3 matrices?
but I think the high score answers are problematic. In particular, they claim that the solution is
$$ X=(B^TB)^{-1}B^TAC^T(CC^T)^{-1}.$$
However, it's unclear that $(B^TB)^{-1}$ and $(CC^T)^{-1}$ exist. In this case, $X$ may not be unique. To force a unique solution, maybe a regularized form is required $$\|A-BXC\|_F^2+\lambda \|X\|_F^2.$$ Are these understandings correct?
By first-order condition, the diffential of the regularized form is $$B^TBXCC^T+\lambda X=B^TAC,$$ but I'm not sure how to merge terms at this points.