In his An Introduction to Substructural Logics, Restall provides the following definition of the string algebra generated by a set (p. 14):
The string algebra generated by a set $X$ is a set $\mathsf{String}(X)$ together with a binary operation $\frown$ (concatenation) on $\mathsf{String}(X)$ satisfying the following conditions:
$X \subseteq \mathsf{String}(X)$.
Concatenation is associative. That is, $a \frown (b \frown c) = (a \frown b) \frown c$ for each $a,b,c \in \mathsf{String}(X)$.
The elements of $X$ are atomic. That is, for each $a \in X$, there are no $b,c \in \mathsf{String}(X)$ where $a = b \frown c$.
Elements are finitely generated. That is, for each $a \in \mathsf{String}(X)$, there are $b_1,\ldots,b_n \in X$ where $b_1 \frown b_2 \frown \ldots \frown b_n = a$.
Strings uniquely decompose. That is, if $a = x \frown b$ and $a = y \frown c$ where $x,y \in X$, then $x = y$ and $b = c$.
He also provides an example of a construction that satisfies these conditions:
There are many ways to construct string algebras. Here is just one — for any set $X$, we define a string of length $n$ to be a function from $\{1,\ldots,n\}$ to $X$. The concatenation of $a$ and $b$, where $a$ is of length $m$ and $b$ is of length $n$, is the string $a \frown b$ of length $m + n$, defined by setting
$$a \frown b(l) = \begin{cases} a(l) & \text{if } l \leqslant m \\ b(l - m) & \text{if } l > m \end{cases}$$ This construction of strings and concatenation of strings satisfies the conditions for a string algebra. We will not stop to go through the details. They are left for Exercise 2.8. (Restall 2000, p. 15)
I am having trouble showing that $X \subseteq \mathsf{String}(X)$ for this example. (I have been able to show that the construction satisfies associativity and unique decomposition, and I have a sense about how to show the other two conditions, based on assumptions about the lengths of elements of $X$. N.B.: I am not a student, and this isn't homework. Just interested logic as a hobby.)
I think my problem might be a matter of the presentation. Intuitively, I get that $X$ is an alphabet and $\mathsf{String}(X)$ contains all of the strings one can form from $X$, so it makes sense that the elements of $X$ are just strings of length $1$. However, for this particular example, strings are functions, and it is not clear to me why, for any set $X$, that $X$ would be a subset of a set of functions.
Is the idea that for any $x \in X$, we can take $x$ to be a function from $\{1\}$ to itself? If so, why?
The set $X$ can be identified with $X^{\{1\}}$. Just map an element $x \in X$ to the function $f$ from $\{1\}$ to $X$ defined by $f(1) = x$.
That being said, the notation you use for the product makes things more complicated than needed. Look at this entry in Wikipedia: free monoid.