Induction.
For three elements it doesn't matter how you place brackets. That's the base case.
Assume that for any combination of $k$ or fewer terms, it doesn't matter how you place brackets. Now take $k+1$ arbitrary elements, and place brackets in two different ways.
By the induction hypothesis, only the outermost pair of brackets could influence the value (anything inside the outermost brackets is $k$ or fewer terms). So, what we have to compare are the values of the two expressions
$$
(a_1\cdots a_i)(a_{i+1}\cdots a_{k+1})\\
(a_1\cdots a_j)(a_{j+1}\cdots a_{k+1})
$$
for some $1\leq i<j\leq k$. Now note that we have
$$
(a_1\cdots a_i)((a_{i+1}\cdots a_j)(a_{j+1}\cdots a_{k+1}))=((a_1\cdots a_i)(a_{i+1}\cdots a_j))(a_{j+1}\cdots a_{k+1})
$$
by associativity on three elements.