Prove the free monoid $M(A)+M(B)\cong M(A + B)$

Suppose you have $h,h'\colon MA+MB\to Z.$ These are distinct if and only if $h\circ i_{MA},h'\circ i_{MA}\colon MA\to Z$ are distinct, or else the ones for $MB$ (because maps out of the coproduct $MA+MB$ are in one-to-one correspondence with cocones on $MA,MB$.) But maps $MA\to Z$ are in one-to-one correspondence with maps $A\to |Z|$ (UMP of free monoids). But distinct maps $A\to |Z|$ means distinct maps $A+B\to |Z|$ (coproducts/cocones again). If those are not distinct (because you stipulate they both equal $f$), then neither are $h,h'.$