Firstly, assume there are two strings $a$ and $b$. Let the GCD of the two strings is the longest string which divides both. String $t$ divides $s$ iff $s = t + t + \dots + t$.
How can I show that a non-trivial GCD exists iff $a + b = b + a$?
One proof I have seen is that: $n \cdot len(gcd) + m \cdot len(gcd) = m \cdot len(gcd) + n \cdot len(gcd)$, but this seems very incomplete.
Assume we are given two non trivial strings $a,b$ such that
$$ a+b=b+a$$
let $len(a) = m$ and $len(b) = n$. W.l.o.g. let $n\geq m$. Then
\begin{align} a_1&=b_1 \\ a_2&=b_2\\ &.\\&.\\&.\\ a_m&=b_m \end{align}
Simply by comparing the strings $a+b$ and $b+a$. So $a$ is a substring of $b$, and specifically,
$$b= a+t$$
So we get
\begin{align} a+a+t&=t+ a+a \\ \end{align}
Where $t$ has length $n-m$
If $n-m>2m$ then $t=2a+q$, so
\begin{align} 4a + q &= 2a + q + 2a\\ \implies 2a + q &= q + 2a\\ \end{align}
Where the total length of the strings on either side of the last equality is $n-m<n+m$.
On the other hand, if $n-m<2m$
Then $2a = t + q$, so we get
\begin{align} t+q+t &= t+t+q \\ \implies q+t &= t+q \\ \end{align}
But still, the total length of the strings on either side is now $2m<n+m$
So notice that given an equality of strings length $m+n$ we can induce a new equality where the strings on either side have a total length of strictly less than $n+m$, if $n\neq m$, by writing the longer string as the shorter one plus some factor. We can keep doing this, shortening the total length of the strings we are comparing, until we reach an expression which cannot be shortened, which is only possible if both strings on either side of the equality have the same length, but that just means they are equal, and so their $gcd$ is just themselves. You can then work your way up again, adding this $gcd$ to itself to get back the original equality, which then necessarily also has some nom trivial divisor, which implies that it has a $gcd$