I provide here a proof for the case $A=\mathcal{O}_{\mathbb{C}^n, 0}$ is the local algebra of holomorphic germs of functions. Surprisingly I haven't found the general statement in the classical books, except the $n=2$ case (intersection multiplicity of plane curves), which can be found e.g. in pg. 38. Fulton. For the proof below thanks to A. Némethi, A. Sándor, P. Frenkel.
I'm curious in which generality is it true for other algebras.
Of course we have to assume that the dimensions are finite. The statement follows from the following lemma by induction:
Lemma: Let $a_1=bc$ a nontrivial decomposition, assume that $c$ is irreducible. Then we have an exact sequence
$$
0 \to \frac{A}{(b, a_2, \dots, a_n)} \to
\frac{A}{(bc, a_2, \dots, a_n)} \to
\frac{A}{(c, a_2, \dots, a_n)}
\to 0.
$$
Proof of lemma: Of course we have an exact sequence
$$
0 \to \frac{(c, a_2, \dots, a_n)}{(bc, a_2, \dots, a_n)} \to
\frac{A}{(bc, a_2, \dots, a_n)} \to
\frac{A}{(c, a_2, \dots, a_n)}
\to 0.
$$
We will be ready if we show that the multiplication by $c$ induces an isomorphism
$$ \mu:
\frac{A}{(b, a_2, a_3 \dots, a_n)} \to \frac{(c, a_2, a_3 \dots, a_n)}{(bc, a_2, a_3 \dots, a_n)}.
$$
Clearly $\mu$ is well defined and surjective. For the injectivity take $x \in A$ such that $\mu[x]=0$, we have to show that $[x]=0$. That is, $cx \in (bc, a_2, a_3, \dots, a_n)$ implies $x \in (b, a_2, a_3, \dots, a_n)$. That is, we assume that
$$cx=l_1 bc+ l_2 a_2 + l_3 a_3 + \dots + l_n a_n$$
holds with some $l_i \in A$, and we want to conclude that there are $l_i' \in A$ such that
$$ x=l'_1 b+l_2' a_2 +l_3' a_3 + \dots + l_n' a_n.$$
From the condition we obtain
$$ c(x-l_1 b)=l_2 a_2 + l_3 a_3 + \dots + l_n a_n.$$
Here we see why the $n=2$ case is special: since $a_2$ is not divisible by $c$, $l_2$ must be divisible, hence we can divide both sides by $c$ and obtain the conclusion with $l_1'=l_1$ and $l_2'=l_2/c$.
For arbitrary $n$ we need some singularity theory. Namely,
$$
\dim \frac{\mathcal{O}_{(\mathbb{C}^n, 0)}}{(a_1, a_2, a_3, \dots , a_n)}
$$
is finite if and only is the common zero set of the germs $a_i$ contains only one ponint, the origin. In this case the ideal $I=I(a_i)_{i=n}^n$ is called complete intersection. Another equivalent algebraic characterization is that $a_i$ form a regular sequence, i.e. for all $i$
$$[a_i] \in \frac{\mathcal{O}_{(\mathbb{C}^n, 0)}}{(a_1, a_2, a_3, \dots , a_{i-1})} $$
is not a zero divisor. I guess it can be found in many books e.g. Looijenga, Mond-Ballesteros.
Therefore $[a_1]$ is not a zero divisor in
$$ \frac{\mathcal{O}_{(\mathbb{C}^n, 0)}}{( a_2, a_3, \dots , a_n)} ,$$
hence $[c]$ is not a zero divisor. That is,
$$ c(x-l_1 b)=l_2 a_2 + l_3 a_3 + \dots + l_n a_n.$$
implies
$$ x-l_1 b=l'_2 a_2 + l'_3 a_3 + \dots + l'_n a_n,$$
what we wanted to prove.