I know how hard it is to feel stupid. I've felt stupid many many times in my life. It doesn't matter whether I fail an exam or have done badly at something simple or have just messed something up. I know what it's like to feel stupid.
I feel stupid because…
These are some of the few reasons I have felt stupid. They're different types of stupid though.
Getting a D in my exam made me feel academically stupid. I felt like a D wasn't good enough and made me feel like I wasn't good enough or I wasn't intelligent enough.
Breaking a glass made me feel like an idiot because how could I have been so careless as to not pay attention to the glass? It made me feel like a stupid careless person.
Throwing a tantrum made me feel stupid because it was so silly. It wasn't worth getting angry over or throwing a tantrum. It was a little thing that was not worth the hassle and distress it caused.
First things first. You're not stupid, however the act may be. For example, when you throw a tantrum. You aren't stupid for throwing a tantrum but the act of actually throwing a tantrum is stupid. So don't say things like ‘I'm so stupid’ or ‘why am I so stupid?’ Instead, acknowledge that what happened was perhaps not the best decision and was perhaps a bit stupid but that doesn't make you stupid.
However stupid what you did may seem, there will always be something worse and even more stupid or more silly. Think of it this way. Once upon a time, there was a feud between the God of Water, Poseidon, and Emperor Caligula. Caligula got so mad that he ordered a wrath on Poseidon. However, because Poseidon was a god and had no physical form, this was a little difficult. So Caligula ordered his soldiers to stab the water. With SWORDS. HE WAS STABBING WATER WITH SWORDS. Of course this wasn't actually attacking Poseidon! How silly is that? See. I'm sure whatever happened was not as stupid as that.
Finally, don't worry about doing something stupid. Everyone doesn't stupid things sometimes. Everyone can be a little bit daft. That's not necessarily a bad thing. Being daft or being silly can be fun. There are times when being serious and sensible are mandatory but being a bit silly is good too. You're not alone in this.
You're not alone in anything.