Derivation from grammar
The grammar as given in your assignment is an abbreviation for the following expanded grammar:
$$P=\left \{
\begin{align}
\begin{aligned}
S &amp;\to \epsilon, \\
S &amp;\to L_a R_a, \\
S &amp;\to L_b R_b, \\ \\
L_a &amp;\to a, \\
L_a &amp;\to L_a a W_a, \\
L_a &amp;\to L_a b W_b, \\ \\
L_b &amp;\to b, \\
L_b &amp;\to L_b a W_a, \\
L_b &amp;\to L_b b W_b, \\
\end{aligned}\qquad\begin{aligned}
W_a a &amp;\to a W_a, \\
W_a b &amp;\to b W_a, \\
W_b a &amp;\to a W_b, \\
W_b b &amp;\to b W_b, \\[8pt]
W_a R_a &amp;\to R_a a, \\
W_a R_b &amp;\to R_b a, \\
W_b R_a &amp;\to R_a b, \\
W_b R_b &amp;\to R_b b, \\[8pt]
R_a &amp;\to  a\\
R_b &amp;\to  b\\
\end{aligned}\end{align}\right \}$$
So, yes, $x$ and $y$ need to be replaced consistently when you expand the shorthand notation. (And it's probably clear why the shorthand was used.)
Intuitively, what's happening here is that $S$ creates a left marker ($L_x$) and a right marker ($R_x$) which will eventually resolve to the same character. The left marker then expands to a sequence of $xW_x$ pairs, where $W_x$ is a &quot;walker&quot;. The $W_x$s all walk to the right; when they finally hit the right marker, they deposit their payload after the right marker. This has the effect of creating two copies of the same string.
In an abbreviated form (combining derivation steps) you get something like this:
$$S\to L_aR_a\Rightarrow L_a b W_b a W_a R_a \Rightarrow L_a b a R_a b a \Rightarrow a b a a b a$$
Filling in the complete derivation would be a useful exercise. (Indeed, it's the exercise you've been asked to do.)