Take theoretical company (Company A) worth $100MM and with a single shareholder (Shareholder A) who owns 100% of the 10MM shares of stock. They "buy" Company B which is also worth $100MM and has a single shareholder (Shareholder B) who owns 100% of Company B's 10MM shares. Company A executes this by issuing 10MM _new_ shares in Company A that will now be owned by Shareholder B. Company A now has 20MM shares and is worth $200MM because it has added Company B's assets, income, etc.
Of course in practice it frequently goes terribly wrong (ref: Microsoft & Nokia, Verizon & Yahoo, many others) and I don't think Google would actually have much incentive to go along with this. Just saying it COULD be done if both companies truly believed the outcome would be favorable.