In a stock purchase, the buyer purchases stock from the owners of the company.
The seller is then taxed on their profit usually at a capital gains rate of 15%.
In an asset purchase, the company is the seller, not the owners.
If the company is a C-corp, profits are taxed first as corporate income to the company. Then, when the profits are distributed to the owner, it will be taxed again as personal income to the owner. The combined rate will usually be higher than 15%.
If the seller is an S-corporation, the profits are taxes only once but may be taxed at a higher ordinary income rate up to 35%.
Consequently, selling stock will net the owners a lower tax rate and more profit after taxes.
Buyers on the other hand will prefer an asset purchase, because the buyer will get a step-up in basis on the purchased assets. The tax basis will be based on the buyer’s purchase price, not the original price that the seller paid, which means less tax on capital gain for the buyer later on. The buyer also gets to depreciation the assets over their full useful life from the time of purchase.
There may be other reasons why a deal gets structured the way it does, but taxation-wise a stock purchase will usually favor the seller and an asset purchase will favor the buyer.