"Star Trek: The Next Generation" is a popular choice for the first category, and "The X-Files" is a popular choice for the second category.
"ST:TNG" was limp, derivative, and boring in its first season (and well into the second season). It wasn't until the third season that the stories became tight, exciting, and complex -- indeed, the third season was responsible for a number of terrific episodes:
Yesterday's Enterprise - a mind twisting, time travel tale with an alternate universe where the Federation is losing a massive war against the Klingons
Sins of the Father - laid the groundwork for the Klingon Civil War, which continued through much of the rest of the show with important ramifications for Worf
The Best of Both Worlds, Part I - the season cliffhanger, with Picard having been Borgified!
Can't argue with that. "ST:TNG" stayed good to its very end. Actually, come to think of it, "Star Trek: Deep Space Nine" also started out slowly but started to get good in season 3, and then really picked it up from seasons 4 to 7.
Meanwhile, "The X-Files" hit the ground running, with seasons 1-3 being the best, in my view. That was when there was enough ambiguity in the government/alien conspiracy that it could still tantalize without contradicting itself. By season 6, however, the whole thing was starting to collapse from its own complexity and ridiculousness, and despite the fine acting by Robert "liquid metal terminator" Patrick as Special Agent Doggett, the show became a rambling mess.
Apart from those two shows, I'd offer two selections of my own. First, for a show that started off lame and then got better, I'd suggest the USA Network version of "La Femme Nikita." I thought the first season had too many missions where Nikita was essentially sent somewhere as a honey trap, over and over. Not only that, Madeleine had a role similar to that in the movie, which is to say, Nikita's hairstylist and manners coach -- BORING! In season 2, however, they gave Nikita more to do, and Madeleine became the ruthless psychological analyst and second in command, which created a more satisfying dynamic within Section One (the counterterrorism unit). Given my preference for serialized shows, I like the fact that beginning in season 3, the writers experimented with longer story arcs, including a tremendous sequence that ended the season and didn't get resolved until four episodes into season 4.
On the other hand, a show that started out great and then devolved into sheer badness was, I'm sad to say, the original "Star Trek." The first two seasons were great and are still fun to watch. The third season, however, began with the so-bad-it's-not-even-fun Spock's Brain and ended with the equally wretched Turnabout Intruder, and in between those two we were treated to space hippies, Melvin Belli as a space demon, cloud miners, Abe Lincoln, an overcrowded planet where people shuffle back and forth(!), and the white-and-black faced (or was it black-and-white faced?) bigots . . . .