The transition from dairy products delivered door to door by the milkman and dairy products sold at supermarkets was not simply a matter of changing the delivery end-point of products, it reflected a shift in the entire production and supply chain which eventually left the milkman out of the loop.
The starting point is the small urban dairy producing raw, unpasteurized milk for local delivery. Out of necessity this process needs to have a minimum of delay because raw milk has a short shelf-life. Dairies would do their best to preserve their milk as long as possible by cooling it in an ice house and delivering it to insulated boxes or pass-thrus customers had at their homes. Individuals would then retrieve the delivered milk in the morning and place it in their ice box (which would ideally also be refreshed with a daily ice delivery). Despite the charming nostalgic vision of a milkman delivering wholesome farm fresh goods to the neighborhood there were a lot of problems with this system. A key one was food safety, raw milk can easily become tainted with a variety of pathogenic microorganisms including salmonella, listeria, e. coli, campylobacter, and even bovine tuberculosis. And these can easily cause foodborne illness which produce symptoms ranging from diarrhea and vomiting to fever and body aches or even death, especially in children. Milk as a source of infectious disease causing childhood illness and death was very much common prior to the 20th century. Additionally, raw unprocessed milk often has highly variable qualities, including varying amounts of milk fat (cream) often becomes separated, and was frequently adjusted or "adulterated" in various ways by dairies (e.g. watering down).
By the early 20th century pasteurization started to become much more common in milk in industrialized countries. And instead of being delivered in open pails milk was delivered in (ideally well cleaned) bottles. This dramatically reduced the incidences of milk borne diseases (along with regulations on dairying and farming practices) but it wasn't perfect. Pasteurization practices were far from uniform, and some were less effective than others. Additionally, the problem of inconsistent milk quality still remained. By the mid 20th century an emerging new standard of milk started to take hold which relied on several innovations and began to become dictated by regulatory standards. Homogenization of milk made it possible to control the milk fat percentage of milks, as well as produce different grades of milk other than simply whole milk (such as 2%, 1%, skim milk, half & half, etc.) Standardization and regulation of pasteurization also increased the safety of the milk supply. But it was the adoption of full control over the end-to-end delivery of milk through the use of aseptic single use containers (typically of waxed paper or plastic) and full refrigeration of milk from just after pasteurization all the way to the point of purchase which would finally virtually eliminate the risk of commercial milk as a source of foodborne illness. Additionally, milk processed and packaged in this way was more consistent in quality and had a shelf-life not just of days but of weeks, and could last for many days before going sour after opening, when kept in a refrigerator.
This occurred with the industrialized of food production in general along with the advent of many new sanitation practices, and the corresponding public enthusiasm for such. Public perception began to see supermarket milk as a more modern and more desirable product. And these changes also encouraged changes in both distribution and consumption. Consumers began buying milk in larger containers (half gallon or gallon jugs) and would buy milk less frequently. And producers began to shift their production away from small dairies located near their customers (dairies used to keep cows actually in cities) and increasingly towards larger more centralized locations in the country.
All of these things occurred at the same time as the rise of automobiles and the rise of suburbanization (in America especially though also in Britain as well) which amplified the effects. Delivering milk every day required both small urban dairy operations and highly centralized urban populations. It's also worth pointing out that this transition also involved consolidation in the dairy industry, especially in the US. The production volumes, supply chain management, and commercial relationships necessary to produce pasteurized milk packaged in aseptic containers and shipped to grocery stores willing to sell them generally favored larger organizations, which meant either larger dairies or conglomerates or coops working together under a single brand name.
Surprisingly, milkmen were able to survive much of this transition but by the end they stopped being an essential step in the process. With homogenized, pasteurized, aseptically contained milk you didn't need daily delivery or short supply lines because the milk had a much longer shelf-life. Also transporting milk in an unrefrigerated vehicle to be left in a cooler on your door step started to seem like a questionable choice as refrigeration became more ubiquitous. And as the food shopping experience transitioned from one where people visited individual establishments (the grocer, the butcher, the cheese shop, etc.) to one where people made one stop to pick up everything from a supermarket which also sold milk the market viability of milk delivery dropped dramatically.
These changes started picking up steam in the 1950s in the US and UK and through the 1960s saw the major market shift to supermarkets and toward supermarket distribution of milk. Additionally, at the same time there were changes in the market and in production which increased demand for more varieties of milk (making doorstep delivery more challenging). Historically the skim milk that results as a byproduct from separating cream from whole milk to make butter was often simply thrown out. During WWII there was heavy demand for milk products for food relief and for feeding soldiers, dried skim milk was a highly effective and low cost method of meeting that demand so during the war production of dried skim milk ramped up massively. After the war the dairy industry tried to find new peace-time markets for skim milk and began marketing it directly to consumers (as both bottled fresh milk and in dried form). Leaning on both the comparatively high-cost of whole milk in the immediate post-war era as well as a deluge of health claims on the advantages of low fat milk, particularly in dieting to reduce or keep down weight, as a means to make skim milk viable in the market. Which carried over to other low fat milks that are now familiar, such as 1% or 2% milk or "semi-skimmed" milk (all possible in the modern era of milk homogenization). This was further amplified by the low-fat diet craze of the 1980s which resulted in consumption of whole milk as being seen as extravagant and outdated (particularly in the US).