There's certainly been more than a few mad admirals not only in Star Trek, but in American sci-fi more broadly. I get the impression that it stems from the broad "ideals" underlying space-oriented sci-fi from the 1960s onwards. Star Trek obviously is one of the most important examples of this - there may be weapons in Star Trek, but ultimately it's all about peaceful exploration, utopian ideas of a galaxy-spanning federation, et cetera. Battles, yes, but only defensive. In short: it's a deeply anti-militaristic setting. I've certainly encountered the same kind of attitudes in a number of sci-fi books from the 1960s onwards. And this filters into even more pro-military settings, like Wing Commander - these things have become standard plot options, to the point where you can easily be 100% pro-military, but you'll still employ this kind of plot because it's a typical sci-fi thing that people are used to.
The mad admiral, I think, stems originally from a mistrust towards career military men, linked to the broader anti-military ideals we see in Star Trek and elsewhere. You can have (you kind of have to) lower-level officers who are great heroes and all that - but hey, they don't issue the broad strategic orders, right? But admirals, who make the big decisions, and are by definition career military officers, are always implicitly mistrusted. They're potentially warmongers, right? Needless to say, even the most anti-militaristic of writers (who are probably a rarity) are not going to paint all admirals with the same brush. Having mad admirals - you know the kind, "deranged by war", ready to "unleash vengeance upon a helpless people" and all that - allows for a story that, while filled with futuristic space battles, will remain at its heart anti-militaristic.
That's how it seems to me, at least. If you think about the ideals behind the first Star Trek series, I'd say there's definitely something to it.