A stock merger occurs when two companies come together to form one bigger company. This is normally done voluntary. On the other hand an Acquisition or takeover occurs when one company buys out another.
Normally one company will lose their stock. Either the company doing the takeover or the company that is formed by the merger can do a variety of things to compensate for the lost shares.
They can choose to pay cash for them, giving the shareholders cash for the lost shares.
They can also give you stock in the new company to replace the stock that was lost. This is done under a conversion ratio (For every 1 share you lost you get X number of shares in the new company).