company A has 90% market share & Company B has 10% market share (we'll be simple to say only 2 in the market)
A looks to buy B, but B cannot sell due to other legal holdings (typically M&A in final negotiation). A agrees to merge with B, then that negotiation occurs. At time of signing an agreement, they go 50:50 on shares to the newly merged company (they retain their previous self-interest shares, which will be diluted as they are sold to the new IPO).