Farmers often know their dogs and what they want and probably really know the lines although it may just appear they cross at random. I know quite a few farmers who know their dogs and their lines. They often talk to me about them. Certainly the breeder/farmers I know are pretty conversant. I know a couple that get semen fro the UK as well to strengthen certain traits in their dogs. Sometimes helpful, sometimes not. If you cross 2 really good proven dogs you increase your chances of good offspring of course. The breeding is planned with the expectation of good dogs.
Some dont of course put too much thought into it and that is obvious in the many poor quality working dogs that are produced. Heavy selection pressure with a bullet is often the end result.
There is often a very heavy selection pressure - I know so many working dogs given away or shot, because they are more of a hindrance than a help, you also see them in the pounds. I have 2 give aways myself to save one from the bullet and one from suburbia and all the training in the world is not going to make them into as a good a dog as my BC, who needs much less training and is a far better dog because he comes from a breeder and stockman who puts a lot of thought into it My neighbour just shot one of his dogs the other day from his own breeding of "good dogs" because it wasnt up to scratch.
There are way too many poor quality working dog produced that end up in not so good circumstances as has been touched on here. In fact the pounds are overflowing with them.