Finding a unambiguous grammar
You can get an unambiguous grammar by thinking of words in $L$ as walks that start and end on the Y axis; each $a$ corresponds to a move $\nearrow$, and each $b$ corresponds to a move $\searrow$. Each such walk can be decomposed into segments of the form $\nearrow \cdots \searrow$ and $\searrow \cdots \nearrow$ which only touch the Y axis at the endpoints. Moreover, this decomposition is unique.

In turn, in a walk of the form $\nearrow \cdots \searrow$, the $\cdots$ part is itself a concatenation of walks of the same form, and this decomposition is unique. Alternatively, if you convert $\nearrow \mapsto ($ and $\searrow \mapsto )$, then walks of the form $\nearrow \cdots \searrow$  become valid strings of balanced parenthesis, surrounded by a pair $()$.

Putting everything together, we get the following unambiguous grammar:
$$
\begin{align*}
&amp;S \to AS \mid BS \mid \epsilon \\
&amp;A \to a X b \\
&amp;X \to AX \mid \epsilon \\
&amp;B \to b Y a \\
&amp;Y \to BY \mid \epsilon 
\end{align*}
$$
Actually proving that this grammar generates $L$ and that it is unambiguous is tedious, and left to you.