Looking at the first season of TOS on IMDB, to remind me, I see the following:
5 Superior beings
2 Spacemen gone wild
1 Transporter accident
1 Sexy robot episode
1 Alternate Earth
1 Shakespeare play
1 A submarine combat
1 Alternate dimension
1 Time travel
That's 14 out of 28. It's 29 if you count the pilot with Pike, but not everyone does.
Most of these are not, to me, gimmicks. Some are weird, but not genre-breaking. Some are just standard (e.g. superior beings).
To me, a gimmick is when the plot seems to be there to service an extreme change in style or form. For example, when the superior being turns the show into a soap opera, right down to the cameras, lighting, and music cues. That's a gimmick. The crew all being muppets is a gimmick. Everything being not just in black and white due to radiation, but the episode also being constructed as 1940s noir is what made that a gimmick. Time travel is not a gimmick, but time travel so we can do Jurassic Park is a gimmick.
I think
Buffy demonstrated how to do gimmicks well. You got one or two per season, and they were both explicable within the overall plot, and were there to serve important character arcs. "The Zeppo" is one of my favourite episodes, emphasizing what makes Xander so vital to the team. "The Wish" not only showed us what could have happened had Buffy never come to Sunnydale, but foreshadowed a huge character shift for Willow. "Hush" wasn't just an awesome mostly dialogue-less episode, it explored the impact of all the secrets that were being kept. "Buffy vs. Dracula" set up character beats that would resonate through the rest of the series, especially for Xander. And, of course, "Once More with Feeling" was a pivotal episode for just about every character, and one of the most beloved because of it.
Gimmick episodes aren't a problem in themselves, they're a problem when the show starts to feel like a delivery mechanism for the gimmicks. Which S4 has
very much become.