Nestle' S.A., the Swiss food giant, announced plans yesterday to buy Carnation Co., one of America's largest food companies, for $3 billion in a deal that will swell Nestle''s already large collection of food products.

The acquisition of Carnation, the nation's largest maker of evaporated milk, will expand Nestle''s large holdings in the international milk business -- just a few months after the end of a seven-year-long worldwide boycott of Nestle' products led by religious, public-service and health groups upset with the company's marketing of baby formula in Third World nations.

But in acquiring Carnation, Nestle' will get more than just "milk from contented cows," as Carnation's long-time advertising put it. Carnation is also a major U.S. marketer of many other products, including diet foods, Carnation Instant Breakfast drink, a line of pet foods, Contadina tomato paste and a variety of packaged prepared foods. Carnation's brand names will be retained by Nestle' after the takeover, a Carnation spokesman said.

Nestle', the world's largest food company, is a major maker and seller of chocolate, coffee, canned fruits and vegetables (through its Libby's brand) and packaged foods (through its Stouffer's brand).

Carnation officials quickly accepted the $83-a-share offer, which ended weeks of speculation on Wall Street that Carnation was being stalked by a potential acquirer. Nestle''s name was perhaps the most commonly mentioned in the takeover rumors, and a Carnation spokesman said Nestle''s was the only offer considered by Carnation's board, which is dominated by members of the founding Stuart family. The Stuarts own about one-third of the company's stock.

The takeover rumors had pushed Carnation's stock steadily higher in recent weeks, and it closed yesterday at $79.50 on the New York Stock Exchange, up $4 a share. Analysts said shareholders of Los Angeles-based Carnation were getting a rich price for their holdings, which were worth about $26 a share in early 1982.

Nestle' is about three times larger than Carnation, which has $3.4 billion in annual sales and is about the same size as such other well-known U.S. food companies as Pillsbury Co. and Campbell Soup Co. Although exact figures on the extent of Nestle''s U.S. holdings are not known, the company's U.S. operations are believed to be about the same size as Carnation.

Despite Nestle''s large marketing operation in the United States, analysts said the company, based in Vevey, Switzerland, has been seeking for some time to expand its U.S. holdings. In addition, company officials were quoted several months ago as having earmarked $2 billion for acquisitions this year.

"Nestle' has been wanting to put money into the domestic market for some time," said Ronald Morrow, a food-industry analyst at Smith Barney, Harris Upham & Co.

Similar desires to increase market share in the highly competitive U.S. food business have led to several other mergers of large food companies in recent years, including General Foods Corp.'s takeover of Oscar Mayer three years ago, Beatrice Companies Inc.'s recent acquisition of another food conglomerate, Esmark Inc., and Ralston Purina Co.'s announcement last week that it would purchase ITT Continental Baking -- maker of Wonder Bread -- from ITT Corp. for $475 million.

But the chairman of the group that coordinated the boycott of Nestle' saw a disadvantage in the company's combination with Carnation. Douglas Johnson, chairman of the Infant Formula Action Committee (INFAC), said he feared the merger could tighten Nestle''s grip on the milk market in several countries where Carnation is its main rival.

On the other hand, he said, Nestle's boycott-ending pledge to improve its marketing practices in Third World countries could correct what Johnson said were similar violations by Carnation.

INFAC led the drive to shun Nestle' products, one of the more effective corporate boycotts ever, to protest Nestle''s hard-sell overseas of infant formula. The protestors charged that Nestle' was endangering the lives of Third World infants by urging their mothers to use the formula -- often mixed with polluted local water -- rather than breast-feed their children. The boycott was ended in January, when Nestle' agreed to change its marketing practices.

Johnson said yesterday that Carnation, though on a smaller scale, has committed violations similar to those of which Nestle' was accused. He said Carnation, using free samples and gifts to mothers, has attempted to market condensed and evaporated milk in Third World countries as a substitute for mothers' milk. INFAC protests to Carnation have been largely unsuccessful, Johnson said.

Carnation's management has a history of being unreceptive to virtually all outside voices. It releases a minimum of financial information, its executives avoid the press, and unlike most public companies, it hardly ever tells the financial community what it is up to.

Nevertheless, it has been one of the most successful U.S. food conglomerates in recent years, enjoying strong earnings and sales growth despite making no major acquisitions for years. Analysts give high marks to the company's management team, and say Carnation will continue to be successful if Nestle' can retain those executives.