It seems like often a when a company announces they will be bought, the stock will immediately jump at a great deal, often instantly. Why exactly does this happen? How do market participants immediately come to agree on a single, much higher price without the market's usual random walk search&discovery?
The price gaps up because the offer is for a price above the current price. Therefore people want to buy now before the price jumps to the offer level.
Of course it does depend on the tone of the announcement, which party is making the announcement, and are they announcing an offer or a deal.
If the price is $10, and the offer is for $12; then the price may quickly jump. The early buyers will make the most quick money. They hope that the deal is done quickly, or if not the final price ends up higher.
There are risks. The company could reject the offer. The due diligence could expose a problem. The regulators could reject the deal based on anti-trust issues. The deal could take many months to complete. Or the final deal could be for shares in the new company.
The risks are one reason people sell after the deal/offer is announced. In other cases the seller finally is seeing a profit, or a smaller loss and wants out while they can.
The "random walk" that you describe reflects the nature of the information flow about the value of a stock. If the flow is just little bits of relatively unimportant information (including information about the broader market and the investor pool), you will get small and seemingly random moves, which may look like a meander. If an important bit of information comes out, like a merger, you will see a large and immediate move, which may not look as random.
However, the idea that small moves are a meander of search and discovery and large moves are immediate agreements is incorrect. Both small moves and large moves are instantaneous agreements about the value of a stock in the form of a demand/supply equilibrium. As a rule, neither is predictable from the point of view of a single investor, but they are not actually random. They look different from each other only because of the size of the movement, not because of an underlying difference in how the consensus price is reached.