Introduction
Quantum Mechanics has many different mathematical objects that are written the same way in the typical physicist's notation. This is not a problem if both the writer and the reader know what meaning was intended, but it can be quite difficult for the freshmen to interpret. Disambiguating all the different meanings is so tiresome that not even mathematical physicists do it properly, but I'll try to be very pedantic in order to highlight all the nuances.
Pedantic notation
It is clear from the equation, that the wavefunction is defined on some part of the 3-dimensional space $\Omega \subseteq \mathbb{R}^3$. Therefore, the Hilbert space we'll be working with is $\mathcal{H} = L^2(\Omega)$. We will use the notation $\mathscr{L}(\mathcal{H})$ to signify the set of all operators from (a dense subspace of) $\mathcal{H}$ to $\mathcal{H}$.
First, we will introduce the multiplication operator. Let $f \in C^\infty(\Omega)$. We define an operator $\hat M_f \in \mathscr{L}(\mathcal{H})$ by
$$
\big( \, \hat M_f \, \psi \, \big)(x) = f(x) \, \psi(x) \: .
$$
There's really nothing special about it, the operator just takes a function $\psi$ and multiplies it by another function $f$. A common physicist would write this just as $f$ or $\hat f$. However, $\hat M_f$ will help us better differentiate between functions and operators.
The multiplication operator has an interesting commutation relation with a the derivative:
$$
\Big[ \frac{\partial}{\partial x}, \; \hat{M}_f \Big]
= \frac{\partial}{\partial x} \hat{M}_f
- \hat{M}_f \frac{\partial}{\partial x}
= \hat{M}_{\frac{\partial}{\partial x} f}
$$
You can check this by applying it to $\psi$.
The equation in question is complicated by the fact that we go from scalars to vectors and back. To properly distinguish the objects, we will give the letters nice hats and arrows:
$$
\begin{align*}
B &\in \mathcal{H} \text{ or } C^\infty(\mathbb{\Omega}) \\[5pt]
\vec{B} &\in \mathcal{H}^3 \text{ or } C^\infty(\mathbb{\Omega})^3 \\[5pt]
\hat{B} &\in \mathscr{L}(\mathcal{H}) \\[5pt]
\hat{\vec{B}} &\in \mathscr{L}(\mathcal{H})^3
\end{align*}
$$
The multicomponent operator $\hat{\vec{B}}$ is really just a triplet of operators $\big( \hat B_x, \hat B_y, \hat B_z \big)$.
It is quite straightforward to generalize the multiplication operator to vectors. Let $\vec A \in C^\infty(\mathbb{\Omega})^3$, we define an operator $\hat{\vec M}_{\vec A} \in \mathscr{L}(\mathcal{H})^3$ by
$$
\hat{\vec M}_{\vec A} = \begin{pmatrix}
\hat M_{A_x} \\
\hat M_{A_y} \\
\hat M_{A_z}
\end{pmatrix}
$$
We also extend the dot product to operators:
$$
\hat{\vec{A}} \cdot \hat{\vec{B}} = \begin{pmatrix} \hat{A}_x \\ \hat{A}_y \\ \hat{A}_z \end{pmatrix} \cdot \begin{pmatrix} \hat{B}_x \\ \hat{B}_y \\ \hat{B}_z \end{pmatrix} = \hat{A}_x\hat{B}_x + \hat{A}_y\hat{B}_y + \hat{A}_z\hat{B}_z,
$$
but now, instead of multiplication, the end result means composition of operators. The notation $\hat{\vec{B}}\vphantom{B}^2$ obviously means $\hat{\vec{B}} \cdot \hat{\vec{B}}$. Finally, we define the operator $\hat{\vec\nabla}$ as
$$
\hat{\vec\nabla} = \begin{pmatrix}
\frac{\partial}{\partial x} \\
\frac{\partial}{\partial y} \\
\frac{\partial}{\partial z}
\end{pmatrix}
$$
Simplifying the equation
Now we're well equipped for the equation in question.
Since $\vec{A}$ is a (smooth) vector field, not an operator, we need to replace it by $\hat{\vec{M}}_{\vec A}$. Then we get:
$$
\begin{align*}
\left( \hat{\vec{\nabla}} + \hat{\vec{M}}_{\vec A} \right)^2 &=
\left( \hat{\vec{\nabla}} + \hat{\vec{M}}_{\vec A} \right) \cdot
\left( \hat{\vec{\nabla}} + \hat{\vec{M}}_{\vec A} \right)
\\
&= \hat{\vec{\nabla}} \!\cdot\! \hat{\vec{\nabla}} \;+\; \hat{\vec{\nabla}} \!\cdot\! \hat{\vec{M}}_{\vec A} \;+\; \hat{\vec{M}}_{\vec A} \cdot\! \hat{\vec{\nabla}} \;+\; \hat{\vec{M}}_{\vec A} \cdot\! \hat{\vec{M}}_{\vec A}
\\
\hphantom{|}
\\
\hat{\vec{\nabla}} \cdot \hat{\vec{\nabla}} &= \frac{\partial}{\partial x}\frac{\partial}{\partial x} + \frac{\partial}{\partial y}\frac{\partial}{\partial y} + \frac{\partial}{\partial z}\frac{\partial}{\partial z} = \hat{\Delta}
\\
\hphantom{|}
\\
\hat{\vec{M}}_{\vec A} \cdot \hat{\vec{M}}_{\vec A} &= \hat{M}_{A_x} \hat{M}_{A_x} + \hat{M}_{A_y} \hat{M}_{A_y} + \hat{M}_{A_z} \hat{M}_{A_z} = \hat{M}_{\left\|\vec{A}\right\|^2}
\\
\hphantom{|}
\\
\hat{\vec{M}}_{\vec A}\cdot\hat{\vec{\nabla}} &= \hat{M}_{A_x} \frac{\partial}{\partial x} + \hat{M}_{A_y} \frac{\partial}{\partial y} + \hat{M}_{A_z} \frac{\partial}{\partial z}
\end{align*}
$$
Since there is no point in expanding $\hat{\vec{M}}_{\vec A}\cdot\hat{\vec{\nabla}}$, as there is clearly no way to simplify it further, we chose to denote it with $\hat\nabla_{\!\vec A}$. If you think about it for a bit, it is the directional derivative operator in the direction of $\vec A$. Now to the last part:
$$
\begin{align*}
\hat{\vec{\nabla}} \cdot \hat{\vec{M}}_{\vec A}
&= \frac{\partial}{\partial x}\hat{M}_{A_x} + \frac{\partial}{\partial y}\hat{M}_{A_y} + \frac{\partial}{\partial z}\hat{M}_{A_z}
\\
&= \left( \hat{M}_{\frac{\partial}{\partial x} A_x} + \hat{M}_{\frac{\partial}{\partial y} A_y} + \hat{M}_{\frac{\partial}{\partial z} A_z} \right) + \left(\hat{M}_{A_x}\frac{\partial}{\partial x} + \hat{M}_{A_y}\frac{\partial}{\partial y} + \hat{M}_{A_z}\frac{\partial}{\partial z} \right).
\end{align*}
$$
This follows from the commutation relation of $\hat M_f$ and a derivative. Now we recognize that on the left side, there's the divergence of the vector field $\vec{A}$, while on the right side that's our familiar $\hat\nabla_{\!\vec A}$. Thus we conclude:
$$
\hat{\vec{\nabla}}\cdot\hat{\vec{M}}_{\vec A} = \hat{M}_{\operatorname{div} \vec{A}} + \hat\nabla_{\!\vec A}.
$$
Finally, putting all this together results in:
$$
\left( \hat{\vec{\nabla}} + \hat{\vec{M}}_{\vec A} \right)^2 =
\hat{\Delta} + \hat{M}_{\operatorname{div} \vec{A}} + 2\,\hat\nabla_{\!\vec A} + \hat{M}_{\left\|\vec{A}\right\|^2} \: ,
$$
which is our desired result.
So no, divergence is not non-associative. There are just two very different operators – directional derivative $\hat\nabla_{\!\vec A}$ and multiplication by divergence $\hat{M}_{\operatorname{div} \vec{A}}$ – which are written the same way due to imperfect notation.