I think more often than not it's a result of weak external hip rotators: glutes, and in particular, glute medius. If anything it's adductor dominance, not weakness, that contributes to the problem.
If your knees come in, your adductors are actually shortening, meaning they are contracting and contributing to the lifting the bar. If your glutes are functioning well, they will externally rotate the hips and push the knees out in the process. The adductors will actually be longer in this position, ie they are doing less work.
Another thing that can help is putting a microband around your thighs, just above the knee, while squatting. It will help cue the knees out and get the external rotators firing properly during the squat.