Law and Order was cancelled after 20 years of television. 20 years. That's longer than DS9, Voy, and Ent COMBINED. And they still managed spin-offs.
If viewers like your product, they will watch.
I suspect L&O was cheaper per episode to produce than DSN, VOY or ENT. But L&O changed cast fairly often, sometimes the new characters where liked other times not so much. If you are looking at the L&O spin offs, the longest running one is SVU, followed by CI. Other spin offs only last 1 season.
It was perhaps a genre which was easier to relate to than a Sci-Fi show. But of course Sci-Fi shows can last longer than 7 or even 10 years.