When companies announce that they are going to be buying other companies, the stock prices of both institutions react. However, they don't usually react the same way. One stock price typically goes up while the other stock price typically goes down.
The stock that usually benefits the most from a merger or an acquisition is the stock of the company that is being acquired. In most cases, the stock price of the company that is being acquired goes up.
The reason the stock price of the company being acquired typically goes up is the company that is doing the acquiring usually pays a premium for the stock of the company it is acquiring. For instance, when Pfizer announced it was going to acquire Wyeth, the price of Wyeth stock jumped higher.
The stock that usually benefits the least—at least in the short term—from a merger or an acquisition is the stock of the company that is doing the acquiring. In most cases, the stock price of the company doing the acquiring goes down.
The reason the stock price of the company doing the acquiring typically goes down is the company is taking on increased risk by acquiring the new company. Companies involved in mergers and acquisitions like to talk about the "synergies" the combination of the two companies will create, but there are no guarantees combining two companies will result in improved performance and profits