In order to adress your question:
But my question is, what if we express x in two different ways, not
just x = $x_1^{a_1}...x_n^{a_n}$? How do we deal with that question?
This is essentially the key observation which justifies the concrete construction of a free group via reduced words.
Take, just for instance, any generating set with two elements such as $\{a,b\}$ where $a$ and $b$ are called letters and all possible linearcombinations (juxtapositions) are words. Let $W=W(\{a,b\})$ be the set of all words. Two elements of $W$ could be $$abb^{-1}a$$ and $$abaa^{-1}b^{-1}a$$
And you might immediately notice that we encounter redundancies within $W$ since even though these two are considered to be two distinct elements in $W$, they would correspond to the same group element if we would start cancelling pairs such as $aa^{-1}, a^{-1}a$ and analogously for $b$.
This leads to the process of reducing words. In Algebra: Chapter $0$ by Paolo Aluffi this is described in a somewhat successive process, so that we successively eliminate cancelling pairs by successively applying a reduction map $$r\colon W(A)\to W(A)$$ given a generating set $A$, observe that in my example we have $A=\{a,b\}$.
Finally, we can define the free group $F(A)$ as the set of all reduced words on the generating set $A$.
There is a function $j\colon A\to F(A)$ defined by sending the element $a \in A$ to the word consisting of the single letter $a$.
Proposition: $j\colon A\to F(A)$ satisfies the universal property for free groups on $A$.
That is, Any function $f\colon A\to G$ extends uniquely to a map $\varphi\colon F(A) \to G$.
I will only provide a quick discussion on this. To check that the extension $\varphi\colon F(A) \to G$ exists as a homomorphism, proceed as follows. If $f\colon A\to G$ is any function, you can extend $f$ to a set-function $$\tilde{\varphi}\colon W(A)\to G$$ by insisting that on one-letter words $a$ or $a^{-1}$ for $a \in A$ it holds that $$\tilde{\varphi} = f(a),\ \tilde{\varphi}(a^{-1}) = f(a)^{-1}$$
and that $\tilde{\varphi}$ is compatible with juxtaposition $$\tilde{\varphi}(\omega \omega') = \tilde{\varphi}(\omega)\tilde{\varphi}(w')$$ for any two words $\omega, \omega'$.
They key observation now is that reduction is invisible for $\tilde{\varphi}$: $$\tilde{\varphi}(R(\omega)) = \tilde{\varphi}(\omega)$$
where $R(\omega)$ is the reduced word of $\omega$. I think that this in particular is what adresses your question.
Anyway, since $\varphi\colon F(A)\to G$ agress with $\tilde{\varphi}$ on reduced words, we have for $\omega, \omega' \in F(A)$ that $$\varphi(\omega\omega') = \tilde{\varphi}(\omega\omega') = \tilde{\varphi}(R(\omega\omega')) = \tilde{\varphi}(\omega\omega') = \tilde{\varphi}(\omega)\tilde{\varphi}(\omega') = \varphi(\omega)\varphi(\omega').$$