For simplicity, consider $X=\{a,b\}$. Let $Y$ be another set in bijection with $X$, and write its elements to be $a^{-1},b^{-1}$.
Let $W(X)$ be the collection of all words in $a,b,a^{-1},b^{-1}$, which can also be though of as collection of finite sequences $(x_1,x_2,\cdots,x_n)$ with each $x_i$ among $\{a,b,a^{-1},b^{-1}\}$ and $n\geq 0$. For $n=0$, we write sequence of length zero to be $1$, call empty word.
On $W$ define multiplication by juxtaposition (as usual, just put one word after another). Define product of any word with $1$ (empty word) to be the same word.
The question I will go to tackle is Is $W$ a group? w.r.t. this product operation? (I tried to solve it in following way, and then finally arrived at a question, mentioned at the end).
Well, it is closed w.r.t. multiplication, which is associative.
Then question of identity comes, but it exists, which is empty word (because, we defined the product of any word with $1$ to be the same word).
Now the question of inverse. What is inverse of $a$?
Well! We define $aa^{-1}=1=a^{-1}a$ and $bb^{-1}=b^{-1}b=1$. Still, we not ensured existence of inverse of each elements, say inverse of $ab$? To do this, we put one more condition on product: define $$(y_1,\cdots, y_n).(x_n,\cdots,x_1)= (x_1,\cdots, x_n).(y_n,\cdots,y_1)=1 \mbox{ if } y_i=x_i^{-1} \,\,\,\,\forall i.$$ Now this may ensure that $W$ is group w.r.t multiplication defined. It seems that the way is not so good. But, I couldn't properly, logically justified why such arguments are not good in the construction of free group. I didn't know if there are any objections in definitions, to convince that the set $W$ is really group.
Question: Can one point out the places of objection in such argument of construction of free group? Say objection on some well-definedness at some places?
Remark: I am familiar with definition of free group, but, I believe that many definition in modern mathematics came with refinement, more refinement, more preciseness in earlier one, and then after some time and effort in the final shape which we see it today; for example, there is a single book devoted to just definition of group. My aim here is to travel from unclear definition to clear definition with proper understanding of logical mistakes in earlier definition. Thanks for the patience!
You say that $W(X)$ is all words, with multiplication defined as juxtaposition, and the empty word as the identity. This is certainly a monoid (it's the free monoid on four generators $a, a^{-1}, b, b^{-1}$), but it can't be a group. Because the product of two words has length the sum of the lengths of the words, no word of positive length has an inverse.
To define the free group it's typical to restrict attention to words in which $a$ never appears next to $a^{-1}$, etc. The underlying set is no longer $W$; it's a proper subset of $W$. The multiplication now involves removing pairs where $a$ appears next to $a^{-1}$ after concatenation, and now you actually need to do some work to prove associativity: you need to know that when evaluating the product $w_1 w_2 w_3$ it doesn't matter whether you do the cancellations involved in computing $w_1 w_2$ first or $w_2 w_3$.