A monoid $M$ satisfies the universal mapping property (UMP) over $X$, if $X \subseteq M$ and for every map $\varphi : X \to N$, where $N$ is another monoid, there exists a unique homomorphism $\varphi : M \to N$ (i.e. this could be thought of as the extension of $\varphi : X \to N$, but this I want to show).
Now I want to show that if $M$ satisfies UMP over $X$, then $M$ is generated by $X$. First I thought that if this is not the case, then there exists some $m \in M$ such that $m$ is not a finite product of some elements from $X$, and this would contradict uniqueness of the homomorphism, as we could map $m$ onto any element from $X$, or to $1$. But in the first place this just gives a map, and it is not clear that this is also a homomorphism (see this related question).
So how to show that $X$ generates $M$?
First choose $N=\langle X\rangle$, the submonoid of $M$ generated by $X$. We obtain (a unique) $\varphi_0:M\to\langle X\rangle$
Now choose $N=M$ and consider $\varphi_1:M\overset{\varphi_0}\to\langle X\rangle\hookrightarrow M$ and $\varphi_2:=id:M\to M$. Both are homomorphisms and extend the inclusion $X\hookrightarrow M$, hence $\varphi_1=\varphi_2$ by uniqueness, which proves the claim since $im\varphi_1=\langle X\rangle$.
By the way, this property also implies that $M$ must be isomorphic to the free monoid $X^*$ over $X$ which consists of finite sequences of $X$ with concatenation as operation.