There is contextual humour and then there is getting evermore jokey. An episode like "I, Mudd, "A Piece Of The Action" or even "The Trouble With Tribbles" would not have been done in the first season and certainly not the third. It's a matter of overall tone.
First season's most humorous episode is "Shoreleave," but it's not an all out comedy. There are dramatic beats to it and even some dark moments. I don't dislike "The Trouble With Tribbles," but I do find it a bit too light. The Klingons have no sense of menace whatsoever. There's no sense that this could be a real problem for the Federation. But I could let "The Trouble With Tribbles" go as a one-off swerve into more overt humour.
"I, Mudd" is different. It totally erases any slight measure of menace Harry Mudd might have once had and makes him a complete buffoon. The androids are depicted in a totally C grade sci-fi cliche manner. This belonged on Lost In Space
and most likely its second or third season. What is sad is that "I, Mudd" has a genuine story with elements of threat and darkness to it that's completely ignored for the sake of a laugh. It pales in comparison to "What Are Little Girls Made Of" and "Requiem For Methuselah."
"A Piece Of The Action" is a genuine oddball because at its heart could well be a very daring story, but it's dressed up in such a way it is very easy to miss. On the surface it's "the gangster planet," a thoroughly absurd concept. What makes it even more absurd is that these are spoofed gangsters and not the more realistically dangerous variety. But what is easy to overlook is how this society is based all an a book. And look how enshrined "The Book" is. "The Book" is essentially the society's Holy Bible. The Iotians based their entire society on a book without even understanding its context. They took it as "truth" in entirety without questioning it in any way.
While on the one hand I can dismiss "A Piece Of The Action" as over-the-top absurdity I can't help but see a profound commentary underneath it. And the more I think about it how else could they possibly comment on this subject in all seriousness unless it was couched as absurdity? Presented as more straightforward drama NBC would never have let it happen.
In full disclosure I never truly realized this before until listening to a podcast discussion regarding this episode (re: Mission Log Podcasts). This issue was raised and a light came on for me the more I thought of it. Holy shit! Are you kidding me? It works that way, too.
Now that said it is still hard to take the rest of it seriously. But the underlying idea is wild especially for the 1960s.