$A$ is a set with elements $a$ and $b$. Here, $a = (a_1a_2...a_n)$ and $b = (b_1b_2...b_m)$.
An operation ($*$) known as $\textit{concatenation}$ is defined on the set. That is, $a*b = ab$.
For example,
if $a = \underbrace{aaaaa}_\text{5 times}$ and $b = \underbrace{bbb}_\text{3 times}$ then $a*b = \underbrace{aaaaa}_\text{5 times}\underbrace{bbb}_\text{3 times}$.
Show that the operation is associative.
My working,
For associativity to hold,
$$(x*y)*z = x*(y*z)$$ but since the set only contains $a$ and $b$, then there would be $(2\times2\times2) = 8$ possible operations i.e.
$$(a*b)*a = a*(b*a)$$ $$(a*b)*b = a*(b*b)$$ $$(b*a)*b = b*(a*b)$$ $$(b*a)*a = b*(a*a)$$ $$(a*a)*a = a*(a*a)$$ $$(b*b)*b = b*(b*b)$$ $$(a*a)*b = a*(a*b)$$ $$(b*b)*a = b*(b*a)$$
So if associativity were to hold, would I need to prove all eight cases?
I'm really not sure if I'm on the right track or completely off.
For case 1, $$(a*b)*a = a*(b*a)$$
$$LHS: (a*b)*a = [(a*b)_1(a*b)_2...(a*b)_n](a_1a_2...a_m) $$
$$=[\left\{(a_1a_2...a_n)(b_1b_2...b_m)\right\}_1\left\{(a_1a_2...a_n)(b_1b_2...b_m)\right\}_2...\left\{(a_1a_2...a_n)(b_1b_2...b_m)\right\}_n](a_1a_2...a_m) $$
$$=[(a_1a_2...a_n)_n(b_1b_2...b_m)_n](a_1a_2...a_m) $$
$$RHS: a*(b*a) = (a_1a_2...a_n)[(b*a)_1(b*a)_2...(b*a)_m] $$
and by the same process we arrive at,
$$=(a_1a_2...a_n)[(b_1b_2...b_n)_m(a_1a_2...a_m)_m] $$
I'm not sure how exactly your definition works, there are some subtleties there (like what exactly $ab$ is?). So let's make it more rigorous:
Let $a=(a_1,\ldots,a_n)$ and $b=(b_1,\ldots,b_m)$ be sequences. For the moment let's forget over what set, it doesn't really matter. I assume that your operation is simply
$$a*b=(a_1,\ldots,a_n,b_1,\ldots, b_m)$$
Now to show that it is associative pick 3 arbitrary sequences $a=(a_1,\ldots,a_n)$, $b=(b_1,\ldots,b_m)$ and $c=(c_1,\ldots,c_k)$. Calculate
$$(a*b)*c = (a_1,\dots, a_n,b_1,\ldots,b_m)*c=(a_1,\dots, a_n,b_1,\ldots,b_m,c_1,\ldots, c_k)$$
On the other hand
$$a*(b*c)=a*(b_1,\ldots,b_m,c_1,\ldots, c_k)=(a_1,\dots, a_n,b_1,\ldots,b_m,c_1,\ldots, c_k)$$
Clearly both sequences are equal which completes the proof. $\Box$
So as you can see you don't have to prove case by case since $a, b, c$ were picked arbitrarly.
Now this general operation is associative. If you restrict it to some smaller set (which it seems you do?) then it still preserves this property.