Company A has 50 billion dollars cash on hand, and their core business is valued by the market at 100 billion, so their market cap is 150 billion. Company B's core business is valued by the market at 25 billion and has no cash on hand, so their market cap is 25 billion.
Company A then purchases company B's core business for 50 billion dollars. Company A then has no cash on hand, their original 100 billion core business, and a new business that the market valued at 25 billion, so their new market cap is 125 billion (a 16.6% decrease).
Company B (or their stockholders, strictly speaking) on the other hand has 50 billion dollars in cash, and no core business, so company B now has a "market cap" of 50 billion dollars (100% increase).
More often than not, the market (i.e. those buying and selling the stocks) will assume that the company being acquired was correctly priced before the purchase and that the acquiring company overpaid.
There are a lot of unknowns, because every deal usually starts from an idea, e.g. we're going to acquire X for $10bn, and that will give us $1bn in extra profits + $2bn in synergies after integration. But they need to integrate the company first to achieve those results, meaning it's unknown, meaning it can fail, meaning there's a risk premium.
Half of what determines the price of a stock on the stock market is psychology. It's a herd.
In the event of a deal, Time Warner shareholders are getting a cash premium SOON. So the price goes up.