We can also look at it this way:
1) In the 22nd century, a shady cabal calling itself "Section 31" as a reference to the UE Starfleet charter, and featuring prominent UE Starfleet Intelligence agents and assorted others in its ranks, engages in illegal operations, with the intent of advancing Earth's cause as chauvinistically as possible. It is not sanctioned, acknowledged or even known about by any part of the government, least of all Starfleet, but it gets to misuse government resources because its members are suitably positioned and capable of committing all sorts of high-level crimes with impunity. This organization trips on its two left feet at some point and ceases to exist, but not before doing damage to the reputation of Earth and its Starfleet Intelligence.
2) In the 23rd century, UFP Starfleet Intelligence is a powerful and competent organization. It has assorted Sections for assorted purposes - and the one tasked with threat analysis and sketching of outlandish responses calls itself "Section 31" as an in-joke, just as it gives its intel cutters NCIA-prefix registries ("Get it, boss, NCIA, huh? Huh?"), maintains a field headquarters at the Lubyanka Station, and otherwise makes fun of the dark history of intelligence gathering. It is reasonably well known in Starfleet circles, as everybody makes good use of the threat analysis, and many are aware of this being conducted by the impressive AI named Control that is apparently of S31 manufacture and, initially at least, has its output filtered through S31. This organization, too, falls out of favor due to mistakes made, but its vital job never goes away - so a bureaucratic sleight of hand results in SF Intel naming its threat analysis force Department 47 instead.
3) The name lives in infamy, though. Assorted cabals keep on cropping up almost weekly, and about 47 of them decide to call themselves Section 31, although at least two accidentally call themselves Section 13 instead. Most have a membership of two, the rest generally featuring just one member who maintains sixteen holoprofiles for those interesting Cabal Tuesday discussions. As of the 2370s, at least one of these cabals is run by a former SF Intel agent who has many holographic friends and occasionally manages to fool real people into his crazy LARP schemes, too.
Timo Saloniemi