Let vectors \(\textbf{v}\) and \(\textbf{u}\) be defined as follows:
$$ \textbf{v} = \begin{bmatrix} v_1 \\ v_2 \\ v_3 \end{bmatrix} \quad \textbf{u} = \begin{bmatrix} u_1 \\ u_2 \\ u_3 \end{bmatrix} $$
Multiplying the vector \(\textbf{v}\) with a scalar \(c\) is done like this:
$$ c\textbf{v} = cv_1 + cv_2 + cv_3 $$
The dot product \(\textbf{v} \cdot \textbf{u}\) is defined as follows:
$$ \textbf{v} \cdot \textbf{u} = v_1u_1 + v_2u_2 + v_3u_3 $$
If we multiply a scalar \(c\) with the above:
$$c (\textbf{v} \cdot \textbf{u}) =c v_1u_1 +c v_2u_2 + cv_3u_3 $$
If we group \(c_i\) with \(u_i\):
$$(cu_1) v_1 + (cu_2) v_2 + (cu_3)v_3 = (c \textbf{u}) \cdot \textbf{v} $$
If we group \(c_i\) with \(v_i\):
$$(c v_1)u_1 +(c v_2)u_2 + (cv_3)u_3 = (c \textbf{v}) \cdot \textbf{u} $$
Therefore, \(c(\textbf{v} \cdot \textbf{u}) = (c \textbf{v}) \cdot \textbf{u} = \textbf{v} \cdot (c\textbf{u})\). A similar proof can be used for other dimensions.