Safeway Stores Inc. announced yesterday that it will install automatic teller machines in nearly two-thirds of its local stores by October, permitting many of its customers to do their banking when they buy their groceries.

The machines can be used to withdraw cash from checking and savings accounts by customers who bank with any of 22 area financial institutions that belong to the Network Exchange, the largest of the area automatic teller networks. Customers can also get balance information, but cannot make deposits because of banking laws. About 1 million households have savings or checking accounts at banks belonging to the Network Exchange.

Network Exchange said it will begin installing the machines in July and by October will have automatic tellers in 93 of Safeway's 151 stores in the region--14 in Washington, 54 in Maryland and 25 in Northern Virginia. Safeway, the area's second-largest supermarket chain, will receive rent from the Network for each installed machine and said to have teller machines in nearly all its area stores eventually.

The joint venture is a major step in the rapidly changing ways financial institutions provide traditional banking services to their customers.

Retailers around the country have been studying the possibility of linking up with banks and other financial institutions ever since technology has made it possible to provide 24-hour banking at sites away from bank branches. Until recently, however, with the advent of shared automatic teller machine systems like Network Exchange, no one bank's teller machines served enough customers to make it worth a retailer's while to install them.

Clifford Logan, vice president for corporate planning at Giant Food Inc., said yesterday that the area's largest food chain does not think it is a good idea to install teller machines yet. He said Giant had been approached by Network Exchange and others, but decided not enough of its customers would be served by any network to justify installation.

At some point, most bankers and retailers agree, competition will give way to cooperation among teller machine networks, and bank customers will be able to use their cards to gain access to their accounts at any bank machine. Supermarkets, which cash billions of checks each year for their customers, are searching for ways to lighten the paperwork load.

There are about 32,000 automatic teller machines in use in the United States today, and the number is growing at a rate of about 25 percent a year. Several hundred regional shared teller machine networks are in operation, and several nationwide networks in various stages of development would permit a New York depositor to get at his or her funds using a San Francisco or Chicago bank's teller machines.

Network Exchange is the biggest area automatic teller system, but the Most system, which just got under way this year, expects to be bigger. American Security Bank, NS&T Bank, Columbia First Federal and Bank of Bethesda are "on line" now. Soon, Perpetual American Federal Savings and Loan and the Bank of Virginia will participate in Most, and about 90 banks have signed up or said they intend to join Most. Bank of Virginia just announced that it plans to put teller machines at five service stations in Virginia.

The third area system, Cash Flow, permits Riggs National Bank customers to use their cards at Virginia National Bank machines and vice versa. Mercantile National Bank of Maryland will join Cash Flow soon.

The banks in Network Exchange and Most (Cash Flow uses a different system) are linked to one another by a computer traffic cop called a "switch." For example, when a Suburban bank customer puts a card in a National Bank of Washington machine, the customer's commands go by telephone line to the switch, which then reroutes those commands to Suburban's computers. Suburban's responses--including authorization to dispense cash--are routed back to NBW via the same switch.

The institutions that are members of Network Exchange are:

Maryland. First National, Union Trust, Suburban, Sandy Spring National, Central National, Savings Bank of Baltimore, Standard Federal S&L, Metropolitan Federal S&L, First Women's, State National, First Continental, Providence and the Safeway Eastern Federal Credit Union.

Washington. D.C. National, National Bank of Washington, Madison National, Security National, Century National and United National.

Virginia. First Virginia, United Virginia and George Mason.