The Midrash (Bereishis Rabbah 20:2) notes that Hashem asked Adam why he ate the fruit, and he answered it was because Chavah told him it was good, and he succumbed. He then asked Chavah why she ate, and she said it's because she listened to the snake. Without letting the snake defend itself, Hashem cursed the snake. Why? Because the snake could have gotten off the hook by claiming "divrei haRav v'divrei hatalmid, divrei mi shom'in" - you, Chavah, should have listened to Hashem, not me. I had no role in your sin; you succumbed to your own Yetzer Hara. It's all your fault.
Now, the snake's not wrong. Divrei HaRav is a valid claim. So why didn't Hashem let the snake defend itself?
עם אדם נשא ונתן, עם חוה נשא ונתן, ועם נחש לא נשא ונתן?! אלא, אמר הקב"ה: נחש זה רשע בעל תשובות, ואם אומר אני לו, עכשיו הוא אומר לי: אתה צוית אותם ואני צויתי אותם, מפני מה הניחו צוייך והלכו להם אחר צוויי?! אלא, קפץ עליו ופסקו ויאמר ה׳ אל הנחש וגו
With Adam He discussed, and with Chavah He discussed, but with the snake He did not discuss?! Rather, Hashem said, "This snake is wicked and is a master of responses. If I talk to him, he'll answer, "You commanded them and I commanded them. Why should they put aside your commandment and go after mine?!" Rather, Hashem cut Him off and said...
As Fred pointed out, the Gemara in Sanhedrin 29a, when discussing this point, says that the reason Hashem didnt talk with the snake isn't because he didn't let the snake talk, but because the snake didn't feel like it. The Midrash, however, clearly says that the reason Hashem didn't let the snake talk is because of the above reason. So, problem #2: Why didn't the Midrash and Gemara give the same explanation?