In evolutionary theory, adaptation is the biological mechanism by which organisms adjust to new environments or to changes in their current environment. The idea of natural selection is that traits that can be passed down allow organisms to adapt to the environment better than other organisms of the same species.
Therefore, the answer is :
Adaptations are mostly random, as they are genetic. They are written in the DNA. Changes in genes are random. If a mutation happens and the offspring of two parents has a mutation, sometimes that mutation will help it live.