I think this is somehow related to the language describing all strings not of the form $ww, w \in \{a, b\}^*$, but I am still not quite sure how. Of course, I have done some thinking and it is evident that the string is just of the form $$\underbrace{w_1w_2\cdots}_{\text{anything}}\underbrace{w_j}_{b}\underbrace{\cdots w_{n - 1}w_nw_{n + 1}w_{n + 2} \cdots }_{\text{anything}}\underbrace{w_{n + j}}_{a}\underbrace{\cdots w_{2n - 1}w_{2n}}_{\text{anything}}$$ When coming to SE, I usually have some work that I have started to go off of, however, I'm not even quite sure how to start on this one. How will the CFG ever know where exactly the indices $j$ and $n + j$ are? It is not clear to me where we can "build out" recursively on a string of this format. Any hints appreciated!
Edit: I am fairly certain that the CFG \begin{align*} S &\rightarrow AB \mid BA \\ A &\rightarrow aAb \mid bAa \mid aAa \mid bAb \mid a \\ B &\rightarrow aBb \mid bBa \mid aBa \mid bBb \mid b \end{align*} works. However, I am not yet entirely convinced intuitively if someone cares to explain.