From Grammarist .com
”To talk out of both sides of one’s mouth means to change one’s advice or opinion depending on who one is talking to or what situation one finds oneself in. For instance, someone who is in the company of people who do not like cucumbers may state that he doesn’t like cucumbers. Later, when he finds himself in the company of people who do like cucumbers, he may state that he does like cucumbers. His opinion is not an honest one; it is a statement he makes to ingratiate himself with the group.”