As Rockwell mentioned, in order to produce milk cows first have to give birth to a calf. Milk is synthesized in the udder by capillaries that are connected to milk alveoli in the udder, where nutrients, immunoglobins, fatty acids, bacteria (most of them good), and hormones are secreted and filtered from the capillaries into milk cells which are secreted into the alveoli. The alveoli cells in the udder act in a similar way to the alveoli in the lungs, only oxygen and carbon dioxide are not being exchanged. And there are many, many alveoli in the udder. Milk that is collected from the milk cells into the alveoli are transported via tubules and tubes which drain into subsequent cisterns, which are finally collected in one big milk cistern in the udder. Milk is held there until it is time for it to be released. Oxytocin from the brain (specifically the hypothalamus) initiates the cow to relax, allong milk to collect in the teat canal which is then "forced" out by the suckling action of the calf, by the vacuum action of the pumps on each teat that collects the milk, or by the pulling and squeezing action of hand-milking.
Colostrum is what is called the "first milk" which is crucial to a baby calf's health. This milk is either collected from the diary cows to be fed to the calf that has been separated, or collected by the calf itself as soon as it is standing and has made its way to its mother's udder. After the colostrum has "gone through" the system, the dairy cows then are able to be put into production to produce milk for us humans. For beef cows, calves are with their mothers until they are weaned, so collecting colostrum for these beef calves are not so much of a problem if they have mom to get it from.