How would you create a Turing machine that copies a string and prints it to the tape?
You are pretty close, here is a TM deciding the language (pseudocode):


Check the input contains a single $\Box$,


If false, reject.

Zig-zag across the tape, check identical letters, and replace them
by $X$.


If not identical, reject.

When all the letters left of $\Box$ are marked $X$, check for remaining
letters right of $\Box$


If there are remaining letters, reject.
Otherwise, accept