He did not think he was a sexist pig. He was very idealistic and talked about the importance of women's rights. It wasn't apparent I was marrying a troglodyte until well after we married and our first child was on the way. On some level, he wanted a modern two career couple lifestyle. But, when push came to shove, he expected me to pick up after him, cook for him, etc. Trying to get him to see where his words and his actions parted ways was very challenging.
A lot of people are like that about various things. This is part of why psychology distinguishes the conscious from the subconscious.
People never have perfect information about their partner. There is a lot dating does not reveal.
(My ex was not a bad guy. I don't hate him and these issues are wholly unrelated to why we divorced.)