Prove that if for all $aba=bab$ then $|G|=1$. Let $G$ be a group such that for all $a,b \in G$ we have $aba=bab$. Prove that $|G|=1$.

So I have to show that $G =\left\{e \right\} $.
Because for any $a,b \in G$ we have $aba=bab$, let $b=e$. Then $aea=eae$ so $a^2 = a$ hence $a = e$. Because $a$ is any we have $G=\left\{e \right\} $.

Does it work?
Your proof works, but it lacks mindless symbol pushing, so I offer two proofs by symbol pushing to restore balance to the world.

Proof I.
Write $abab$ in two ways: $babb=aaba$. Then: $$aaba=b(ab)b=abbab$$ And cancel to get $aba=bbab$, but $aba=bab$, so $b=e$. $\square$

Proof II. We start with the natural equation
$$baab=aabaa=ababa=babba$$ Now, cancel $ba$ on the left, so that $ab=bba$. But $$aba=bab\implies ab=baba^{-1}$$ Therefore, $bab=bbaa$ and so $ab=baa$ as well. This means $bba=baa$; cancelling on both left and right, $b=a$. Since $a,b$ are abitrary, we are done. $\square$
I make it more detail:

G is a group => e $\in$ G. i.e., |G| >= 1

for some x $\in$ G

1, if $x^{-1}$ not x: |G| >= 3 (at least x, $x^{-1}$, e)

$x^{-1}$x$x^{-1}$ = x$x^{-1}$x, so x=$x^{-1}$

This is to say, for all x $\in$ G, x=$x^{-1}$

2, for any x $\in$ G, since x=$x^{-1}$: x=exe=xex=xe$x^{-1}$=e. so x=e

So G={e}, |G|=1

QED