In X-Men: Days of Future Past, Magneto is shown commanding one of the Sentinels to
"Do what you were made for!"
Why would the Sentinels accept any voice command from Magneto?
Science Fiction & Fantasy Stack Exchange is a question and answer site for science fiction and fantasy enthusiasts. It only takes a minute to sign up.Sign up to join this community
In the scene where Magneto infiltrates metal into the bodies of each of the sentinels, there's a "blink and you'll miss it" animation where the metal invades the CPU of the robot, activating it and (presumably) allowing Magneto to take control of it.
Quite how he reprograms them isn't described in detail but as the old adage goes, there's no access like physical access.
Just a thought but maybe he put them in "opposite mode". Instead of killing mutants & protecting humans, they somehow where switched to killing humans and protecting mutants. Just a guess from observing the behavior of sententials in the past