In Biblical times yeast was not available in little packets as it is today. Instead flour and water were left exposed to the air where wild yeast would find it and begin to multiply. Over time a lump of yeast rich "sourdough starter" would develop. A piece of this "starter" would added to a new batch of flour and water and allowed to sit and the yeast would cause the new lump to rise:
BSB Luke 13: 20Again He asked, “To what can I compare the kingdom of
God? 21It is like yeast that a woman took and mixed into three
measures of flour until all of it was leavened.”
A properly cultivated starter is an heirloom today because not all yeast is the same and it can take many years to raise a quality starter. The nature of the starter influences the resulting bread's flavor and texture.
The use of leaven was extremely common as bread was a staple of the Mediterranean. Jesus and Paul both used it in metaphor and in parables. It must not have been commonly used in metaphor before Jesus since the disciples didn't "get it" when he issued the warning.
Leaven wasn't intrinsically a bad thing and in the use of the 3 loaves cited above it was a positive image of the power of reproduction (disciples begetting disciples perhaps) and influence.
In the NT Paul used the metaphor to refer to pride, where people were observing the Passover with unleavened bread but in their hearts they were self-congratulatory rather than mourning for their sins, which was the point of the feast of unleavened bread.
In Luke 12 it is specifically said to be used as a metaphor for hypocrisy, where what is done in public does not match what is done in private:
NIV Luke 12: 1Meanwhile, when a crowd of many thousands had gathered,
so that they were trampling on one another, Jesus began to speak first
to his disciples, saying: “Be on your guard against the yeast of the
Pharisees, which is hypocrisy. 2There is nothing concealed that will
not be disclosed, or hidden that will not be made known. 3What you
have said in the dark will be heard in the daylight, and what you have
whispered in the ear in the inner rooms will be proclaimed from the
roofs.
But in the Matthew 16 version the focus is on the teaching:
NIV Matthew 16: 5When they went across the lake, the disciples forgot
to take bread. 6“Be careful,” Jesus said to them. “Be on your guard
against the yeast of the Pharisees and Sadducees.” 7They discussed
this among themselves and said, “It is because we didn’t bring any
bread.” 8Aware of their discussion, Jesus asked, “You of little faith,
why are you talking among yourselves about having no bread? 9Do you
still not understand? Don’t you remember the five loaves for the five
thousand, and how many basketfuls you gathered? 10Or the seven loaves
for the four thousand, and how many basketfuls you gathered? 11How is
it you don’t understand that I was not talking to you about bread? But
be on your guard against the yeast of the Pharisees and Sadducees.”
12Then they understood that he was not telling them to guard against
the yeast used in bread, but against the teaching of the Pharisees and
Sadducees.
While Jesus does not here explain what was the issue in the teaching of the Pharisees or the Sadducees, and they would have had different teachings (often diametrically opposed) they apparently had some things in common. The diatribe in Matthew 23 has many examples of their hypocrisy and this section seems to be focused on their teachings:
NASB Matthew 23: 16“Woe to you, blind guides, who say, ‘Whoever swears
by the temple, that is nothing; but whoever swears by the gold of the
temple is obligated.’ 17“You fools and blind men! Which is more
important, the gold or the temple that sanctified the gold? 18“And,
‘Whoever swears by the altar, that is nothing, but whoever swears by
the offering on it, he is obligated.’ 19“You blind men, which is more
important, the offering, or the altar that sanctifies the offering?
20“Therefore, whoever swears by the altar, swears both by the altar
and by everything on it. 21“And whoever swears by the temple, swears
both by the temple and by Him who dwells within it. 22“And whoever
swears by heaven, swears both by the throne of God and by Him who sits
upon it.
While there are other teachings that could be cited we see in this one that these "blind guides" practiced a kind of "binding and loosing" where they held some practices to carry obligation while others were free of obligation. Jesus held that every idle word had obligation.
In fact, when Jesus gave his Royal Law on the mountain and on the plain it shocked the hearers because his teaching was so different from that of the scribes and Pharisees:
NASB Matthew 5: 17“Do not think that I came to abolish [parse into
obligatory and non-obligatory] the Law or the Prophets; I did not come
to abolish [parse into obligatory and non-obligatory] but to fulfill
[restore the integrity of the law]. 18“For truly I say to you, until
heaven and earth pass away, not the smallest letter or stroke shall
pass from the Law until all is accomplished. 19“Whoever then
annuls one of the least of these commandments, and teaches others to
do the same, shall be called least in the kingdom of heaven; but
whoever keeps and teaches them, he shall be called great in the
kingdom of heaven. 20“For I say to you that unless your
righteousness surpasses that of the scribes and Pharisees, you will
not enter the kingdom of heaven.
NASB Matthew 7: 28When Jesus had finished these words, the crowds
were amazed at His teaching; 29for He was teaching them as one
having authority, and not as their scribes.
One could also point out their penchant for adding to the scriptures:
NIV Mark 7: 1The Pharisees and some of the teachers of the law who had
come from Jerusalem gathered around Jesus 2and saw some of his
disciples eating food with hands that were defiled, that is, unwashed.
3(The Pharisees and all the Jews do not eat unless they give their
hands a ceremonial washing, holding to the tradition of the elders.
4When they come from the marketplace they do not eat unless they wash.
And they observe many other traditions, such as the washing of cups,
pitchers and kettles.a )
5So the Pharisees and teachers of the law asked Jesus, “Why don’t your
disciples live according to the tradition of the elders instead of
eating their food with defiled hands?”
6He replied, “Isaiah was right when he prophesied about you
hypocrites; as it is written:
“ ‘These people honor me with their lips, but their hearts are far
from me. 7They worship me in vain; their teachings are merely human
rules.’b 8You have let go of the commands of God and are holding on to
human traditions.”
9And he continued, “You have a fine way of setting aside the commands
of God in order to observec your own traditions! 10For Moses said,
‘Honor your father and mother,’d and, ‘Anyone who curses their father
or mother is to be put to death.’e 11But you say that if anyone
declares that what might have been used to help their father or mother
is Corban (that is, devoted to God)— 12then you no longer let them do
anything for their father or mother. 13Thus you nullify the word of
God by your tradition that you have handed down. And you do many
things like that.”
14Again Jesus called the crowd to him and said, “Listen to me,
everyone, and understand this. 15Nothing outside a person can defile
them by going into them. Rather, it is what comes out of a person that
defiles them.” [16]f
17After he had left the crowd and entered the house, his disciples
asked him about this parable. 18“Are you so dull?” he asked. “Don’t
you see that nothing that enters a person from the outside can defile
them? 19For it doesn’t go into their heart but into their stomach, and
then out of the body.” (In saying this, Jesus declared all foods
clean.)
20He went on: “What comes out of a person is what defiles them. 21For
it is from within, out of a person’s heart, that evil thoughts
come—sexual immorality, theft, murder, 22adultery, greed, malice,
deceit, lewdness, envy, slander, arrogance and folly. 23All these
evils come from inside and defile a person.”
By amplifying the simple commands of the scriptures into more complex and often more demanding obligations they were essentially acting like leaven, inflating the command into a bloated and vexing version of itself such that the original command was ultimately displaced with their traditions.