The correct option is (C) would have avoided.
The complete sentence: "If we had consulted the engineer, we would have avoided this mistake."
This is a third conditional sentence (past unreal condition). When the if-clause uses had + past participle, the main clause must use would have + past participle to express a hypothetical past situation that did not actually happen.