This is confusing. Did you use actual individual variables of the formal language to write the axiom? Or perhaps are $x_1$ to $x_6$ metavariables (metamathematical variables)? If these are individual variables, then this wff is not the REP scheme (without parameters), because the metamathematical variable $\mathscr{A}$ (which represents some wff) has fixed individual variables $x_1$ and $x_2,$ being functional on $x_2$ with $x_1$, and one cannot introduce $x_5$ and $x_6$ in the consequent, except in the case of substitutions of variables (and perhaps this is what you meant whith the brackets "$\mathscr{A}(x_6,x_5)$"), but this is unnecessary. Being $x_1$ to $x_6$ individual variables, of course they are all distinct. Make sure $x_4$ is not free in $\mathscr{A}$ and just repeat $x_2$ and $x_1$ in the consequent like this
$$((\forall x_1)(\exists! x_2) \mathscr{A}) \to (\forall x_3)(\exists x_4)(\forall x_2)((x_2 \in x_4) \leftrightarrow (\exists x_1)((x_1 \in x_3) \wedge \mathscr{A}))$$
and we are done.
Note that we can interchange the individual variables by others not occurring on the scheme by means of some alphabetic variant (meta)result.
On the other hand, if $x_1$, ..., $x_6$ are metavariables, then one has to make explicit they represent distinct individual variables, except that $x_6$ is $x_1$ and $x_5$ is $x_2$ or they are all distinct and the string $\mathscr{A}(x_6,x_5)$ is the wff obtained from the wff $\mathscr{A}(x_1,x_2)$ by replacing $x_1$ by $x_6$ and $x_2$ by $x_5$ where they are substitutable.