That's right! It did not happen by chance.
Evolution is restricted by the nature of molecular biology. It's restricted by the constraints of developmental biology during development. It's restricted by the laws of physics and chemistry
Most importantly, evolutionary change is governed by natural selection, and natural selection is not a random process.
Natural selection selects for successful combinations of characteristics that give the possessor an advantage over those who do not have the particular characteristic. For example, better hearing so one can hear an enemy approaching. Those with that particular trait will tend to live longer and procreate more than those less fortunate in the hearing department. That's "natural selection". It is not chancy at all.