Looking back through the history of a species' genome, mutations do indeed appear to be attracted to certain genomic locations (and likewise repelled by others). But appearances can be deceiving, and selection is a great illusionist. Mutations that initially occur at random may end up seeming to be "directed" in highly nonrandom patterns since most mutations that occur are quickly lost from the population, often in just one generation. The relatively few mutations that are not lost are the ones that contribute to evolutionary change.
Within a population, each individual mutation is extremely rare when it first occurs; often there is just one copy of it in the gene pool of an entire species. But huge numbers of mutations may occur every generation in the species as a whole. At more than six billion individuals, the human species is now so large that every single base pair of the three billion in the genome is mutated several times, somewhere in the population, every generation. Some of these mutations are so harmful that they're eliminated before their carriers are even born. But the great majority of mutations are harmless (or at least tolerable), and a very few are actually helpful. These enter the population as exceedingly rare alternative versions of the genes in which they occur.
Most new mutations are going to be lost just because they are rare (even if they are beneficial); however, very small effects on survival and reproduction may greatly affect the long-term rates at which different mutations accumulate in particular genes and at particular sites within genes. The result is a pattern of evolutionary change that looks nonrandom and in fact really is nonrandom: some sites almost never change, some change occasionally and others change relatively often.
But this does not mean that the mutations themselves occurred nonrandomly. In retrospect, it's as if they occurred where needed. But in fact they just accumulated where needed—first one, then another, and another, over very many generations. Getting two or more helpful mutations together in the same genome may take a while, but if they are not lost from the population, then this will eventually happen in a sexual species.
Sometimes, looking back, biologists can infer that an eye or some other complex adaptation was assembled in a particular way (through a particular sequence of evolutionary changes). This leads naturally to the thought that this adaptation had to be assembled in that particular way, following exactly that sequence of mutations. But a great deal of evidence and theory shows that this is almost never true.
A crude and relatively ineffective light-sensing organ may be much better than none at all, and there may be thousands of different mutations that would slightly improve its functioning in different ways. When one of them occurs and is lucky enough not to be immediately lost and then rises in frequency within the population, it sets the stage for others. But there's no way to predict which mutation will be the next to succeed.
Some recent human adaptations with known genetic histories nicely illustrate this principle. For example, the widespread but not universal ability to digest the milk sugar lactose in adulthood (lactose tolerance) has recently been shown to arise from any of several different mutations in and near the lactase gene. These occur in geographically isolated populations descended from early pastoralists who lived in different parts of Africa and Eurasia. In this case as in others, there appears to have been much randomness in the process that determined which of many possible mutations would be the one that ended up answering the call at a given time and place.
Perhaps it was predictable that adaptation to a novel food resource (the milk of domesticated cows and goats) would occur, but apparently it was not predictable, even in principle, exactly how it would occur.