Given a generating set $G$ (assume for simplicitly it consists entirely of urelements), the free magma on $G$ can be described concretely as follows.
Its underlying set is the least $U \supseteq G$ closed under the formation of ordered pairs; meaning that if $x,y \in U$, then $(x,y) \in U$.
The law of composition is given by $xy = (x,y)$.
Now this is a very materialistic way of talking. Is there a way to recast the above description to be more structuralist in flavour? For example, I would like the description to go through in ETCS.
Let $(\mathcal{C},\otimes)$ be a monoidal category with countable coproducts (denoted by $\coprod$), such that each endofunctor $X \otimes -$ and $- \otimes X$ preserves countable coproducts. For example it could be a cartesian closed cocomplete category such as $\mathsf{Set}$ (with $\otimes=\times$ and $\coprod = $ disjoint union) or any model of ETCS. Recall that a magma in $\mathcal{C}$ is an object $M$ equipped with a morphism $M \otimes M \to M$. These constitute a category $\mathsf{Mag}(\mathcal{C})$. There is a forgetful functor $\mathsf{Mag}(\mathcal{C}) \to \mathcal{C}$. I claim that it has a left adjoint, thus mapping $X \in \mathcal{C}$ to the free magma $F(X)$ over $X$.
We define the underlying object to be $F(X) := \coprod_{n \geq 1} F_n(X)$, where $F_n(X)$ is defined recursively by $F_1(X)=X$ and $F_n(X) = \coprod_{p+q=n} F_p(X) \otimes F_q(Y)$. This simple definition creates all possible tensor brackets of $X$: For example,
$\begin{align} F_2(X) = & X \otimes X \\ F_3(X) = & X \otimes (X \otimes X) ~\sqcup~ (X \otimes X) \otimes X \\ F_4(X) = & X \otimes (X \otimes (X \otimes X)) ~\sqcup~ X \otimes ((X \otimes X) \otimes X) ~\sqcup~ (X \otimes X) \otimes (X \otimes X)\\ & \sqcup ~(X \otimes (X \otimes X)) \otimes X ~\sqcup ~ ((X \otimes X) \otimes X) \otimes X. \end{align}$
We have canonical morphisms $F_n(X) \otimes F_m(X) \to F_{n+m}(X)$. These induce a morphism $F(X) \otimes F(X) = \coprod_{n,m \geq 1} F_n(X) \otimes F_m(X) \to F(X)$. This way $F(X)$ becomes a magma. We have the inclusion $X=F_1(X) \to F(X)$.
Now let us prove the universal property. Let $(M,m : M \otimes M \to M)$ be any magma and $h : X \to M$ be a morphism. Define $h_n : F_n(X) \to M$ with $h_1=h$ by induction on $n$: We extend $F_p(X) \otimes F_q(X) \xrightarrow{h_p \otimes h_q} M \otimes M \xrightarrow{m} M$ to the direct sum $h_n : F_n(X) \to M$. These induce a morphism $h : F(X) \to M$, which is actually a morphism of magmas by construction, and clearly the unique one extending $h$.
Almost every construction basic algebra can be carried out in any cocomplete (symmetric) monoidal category.