Let $(X,\circ,e)$ be a monoid, for set $X$, binary operation $\circ$, and identity element $e$.
Suppose $$ A_1 \circ A_2 \circ \ldots \circ A_n = B_1 \circ B_2 \circ \ldots \circ B_n = C, $$ where the A's, B's, and C belong to X with the property that if any $At = x \circ y$ for some $x$ and $y$ in $X$, then one of $x$ or $y$ is $At$ and the other is $e$. Similarly for any $Bt = x \circ y$ for some $x$ and $y$ in $X$.
If $n$ is such that for all other $D_1 \circ D_2 \circ \ldots \circ D_m = C$, where $D$'s belong to $X$ and $Dt = x \circ y$ implies one of $x$ or $y$ is $Dt$ and the other is $e$, then $m \ge n$, is it true that $A_1= B_1, A_2 = B_2, \ldots , A_n = B_n$?
For ease of discussion, call an element $a \in X$ an atom if, for all $x, y \in X$, $a = x \circ y$ implies $x = e$ or $y = e$.
If I understand the question correctly, it is asking if, for any monoid $X$, and any positive integer $n$: if an element $C \in X$ cannot be expressed as a product $D_1 \circ D_2 \circ \ldots \circ D_m$ of $m < n$ atoms in $X$, but $C$ can be expressed as a product of $n$ atoms $A_1 \circ A_2 \circ \ldots \circ A_n$ in $X$, then the latter expression is unique.
There are several problems with this. I'll try to tease them out one by one.
The first problem is that $e$ might itself be an atom (this is so, for example, in the monoid of strings over an alphabet), but it is not clear whether you actually mean to include this case. (I won't speculate.)
The second problem is that if $X$ is commutative, and has at least two distinct atoms (for example, $X$ might be the monoid of positive integers under multiplication, when the atoms would be the primes, and possibly also $1$), and if $C$ is a product of two distinct atoms, neither of which is $e$ (for example, if $C = 6$), then the proposition would fail for $n = 2$.
It seems obvious that you meant to exclude that case. But it is not obvious (at least not to me) how you meant to exclude it. Perhaps you require $X$ to be a free monoid? Then I think the proposition would be true for all $n$ (and it wouldn't matter whether $e$ was counted as an atom or not). But that would be a very strong requirement, and it would certainly need to be made explicit. Also, in that case, the proposition is virtually trivial.
Finally, I think this is the multiplication table of a monoid in which (i) $a$ and $b$ are atoms, (ii) $ab \ne ba$, (iii) $d$ is not an atom, and (iv) $a^2 = ab = d$; so it is a counterexample for $n = 2$, in which commutativity is not to blame for the failure of the proposition (in the table, $x \circ y$ is in row $x$, column $y$): $$ \begin{array}{c|ccccc} \circ & e & a & b & c & d \\ \hline e & e & a & b & c & d \\ a & a & d & d & d & d \\ b & b & c & d & d & d \\ c & c & d & d & d & d \\ d & d & d & d & d & d \end{array} $$ Proof. There are $5^3 = 125$ equations of the form $(uv)w = u(vw)$, where $u, v, w \in \{e, a, b, c, d\}$. If any of $u, v, w$ is equal to $e$ (the identity element), then the equation is true. We are left with the $4^3 = 64$ equations with $u, v, w \in \{a, b, c, d\}$. Then $uv, vw \in \{c, d\}$, so $(uv)w $ and $u(vw)$ are both equal to $d$, and the equation holds again. Therefore $\circ$ is an associative operation, with identity element $e$. $\square$