Various definition of monoids I saw that monoids arise in two  different situations, that I briefly describe below. It is inevitable that there are some analogies between such situations, but I can't understand if there is  some deeper connection / point of view that I don't see,  or they are just two ways of recovering monoids. Thanks.
Monoidal object in sets. $(\mathbf {Set},\times,\{*\})$ is a monoidal category, and a monoidal object is a set $M$ together with two maps $\mu:M\times  M\to M$ and $\eta:\{*\}\to M$ satisfying the known commutative diagrams. Hence $M$ is given a structure of monoid, choosing the image of $\eta$ as identity and calculating the product of two elements with $\mu$.
Algebra over a monad. $(\operatorname{End}(\mathbf{Set}),\circ, \operatorname{id}_\mathbf {Set})$, the (strict) monoidal category of endofunctors on sets, with the composition and the identity functor. A particular monoidal object is the functor sending a set $S$ to  the underlying set of the free monoid over $S$ (for free monoid over $S$ I mean the set of words over $S$, with product the concatenation and identity the empty word). An algebra over this monad is again a monoid, but in a different way from before: here the product is defined not only on pairs but for arbitrary sequences of elements, and the identity is the image (via the structural  map of the algebra) of the empty word.
 A: So to establish notation, let $\def\sC{\mathscr{C}}\def\bI{\mathbb{I}}(\sC,\otimes,\bI)$ be a monoidal category, and denote by $\def\Mon{\mathbf{Mon}}\Mon(\sC)$ the category of monoid objects in $\sC$.
This category has a canonical forgetful functor $U:\Mon(\sC)\to\sC$, and we have the following result:

Theorem. If $(\sC,\otimes,\bI)$ is a locally $\lambda$-presentable closed symmetric monoidal category, then $\Mon(\sC)$ is locally $\lambda$-presentable, and $U:\Mon(\sC)\to\sC$ is finitary monadic.

This is Theorem 2.1 on the $n$Lab page on the category of monoids.
Let $\sC$ be as in the theorem, then unpacking the statement, we have in particular:

*

*The existence of a "free monoid" functor $F:\sC\to\Mon(\sC)$: indeed, it is the left adjoint $F\dashv U$.

*If we let $T := UF$ be the induced monad on $\sC$, then $\Mon(\sC)$ is canonically equivalent to the category $\sC^T$ of algebras for the monad $T$.

In particular, if you take $(\sC,\otimes,\bI) = (\mathbf{Set},\times,*)$, then you recover the monoids you describe in your question.
Under the hypotheses of the theorem, the free monoid monad takes a very similar form to the usual "free monoid" construction in $\mathbf{Set}$: precisely, given an object $X$ of $\sC$, the free monoid is the coproduct
$$
X^* := \coprod_{n\geq0}X^{\otimes n} = \bI\sqcup X\sqcup(X\otimes X)\sqcup(X\otimes X\otimes X)\sqcup\dots
$$
The closed symmetric monoidal structure on $\sC$ is necessary to ensure that the tensor product distributes over the coproduct and defines a monoid multiplication $X^*\otimes X^*\to X^*$.
In particular, an algebra for the free monoid monad is an object $X$ with a suitable action $\nu:X^*\to X$, and by the universal property of the coproduct, this amounts to specifying for every $n\geq0$ a "$n$-ary multiplication" map $X^{\otimes n}\to X$.
This is an unbiased definition of a monoid object in $\sC$.
To summarise: the notion of a "monoid object" in $(\sC,\otimes,\bI)$ is probably "more general" than the notion of an "algebra for the free monoid monad" (as the latter probably only really makes sense when most of the hypotheses of the above theorem hold), but the equivalence of the two notions holds in rather great generality.
