Tremper Longman writes: "This sounds like a direct contradiction to verse 5. Should a person answer a fool or not?
"This proverb pair is prime evidence leading toward the proper understanding of the proverb genre. Proverbs are not universally true laws, but circumstantially relevant principles (sort of in the vein of “He who hesitates is lost,” and “Fools rush in”). In short, the answer depends on the nature of the fool with whom one is engaged in conversation. In other words, the wise person must assess whether this is a fool who will simply drain one’s energy with no positive results or whether an answer will prove fruitful to the fool or perhaps to those who overhear. The wise not only know the proverb but also can read the circumstances and the people with whom they dialogue."
Keil & Delitzsch:
"[Verse 5] is not a contradiction to verse 4. We should answer a fool in ways appropriate to answer a fool: make short work of it, point out the absurdities, and reject his logic. By doing such we can help a fool in understanding their folly and put them on the right path. Otherwise we enable a false sense of self-importance."