He does that because he compares you with the person he is having an emotional affair with. And in case you say something that can slightly offend that person, he will be extremely defensive towards her. He might put you down because you are not like the person he is having an affair with.