You're right and evolution is easily misunderstood as deterministic when it is only the result of random mutations in a population over time. Every variation you see does not mean it has a positive evolutionary advantage, only that those it wasn't prohibitive to reproduction