In "Inquisition," Sloan claims that Section 31 was "part of the original Starfleet Charter." He makes no reference to it being part of the current Federation Starfleet Charter.
In ENT, we hear that Article 14, Section 31 of the United Earth Starfleet Charter establishes that certain rules can be "bent" during times of extraordinary crisis. Nothing about Article 14, Section 31, of the UESF Charter is said to establish a permanent organization with carte blanche
to violate all law. Nor is there any indication that the United Earth Starfleet Charter is still in force in the era of the Federation Starfleet.
Further, "Inquisition" makes it clear that Section 31 does not answer to anyone in the Federation government. This is backed up by "Extreme Measures," which establishes that Section 31 even spied on the Federation President himself.
So it's obvious that Section 31 is not a government agency. It doesn't answer to the government in any way. Nor is it authorized by the UESF Charter, even if its members like to pretend it is.
Section 31 is just an organized crime syndicate within the government and military, that's all. It's the equivalent of the Deep State
in Turkey or of Mafia agents in the police, not the CIA or FBI.
Regarding the charters: As I said earlier, we don't know that aspect of the charter did not make it into the federation charter.
But nothing that has been established in any way implies that it's legal for an organization to have carte blanche
in violating the law. Not even the novels' reference to the Federation Starfleet Charter establishing an "autonomous investigative agency" with "discretionary power" over "non-specific issues." Nothing at all
we have seen in any way establishes legal grounds for Section 31's claim to be above the law, and nothing canonically
even establishes legal grounds for Section 31 to exist as a government organization of any kind.
Re: Spying on the President: This doesn't prove official status one way or another. For all we know, Section 31 isn't under Presidential oversight. In the American government, the Congressional Budget Office is a fully sanctioned government office staffed with civil servants who do not answer the Executive Branch.
1. If Section 31 were legally a part of Starfleet, then it would be part of the military and of the executive branch. That means that it would legally answer to the President, not the Council, as DS9's "Homefront" two-parter explicitly established that the President is the commander-in-chief.
2. The Congressional Budget Office works for Congress, not the President, but that doesn't mean they get to spy
on the President. Espionage against the President is patently illegal, and is an absolute indicator that Section 31 is a criminal conspiracy within the government, not a legitimate agency.
Additionally, if it were just another criminal enterprise, why wouldn't Starfleet (Starfleet as a whole, not just our main cast on DS9) or Federation Security try to take them down, as they did with the Maquis?
Because the conspiracy includes powerful people in high-level positions within the military and government who stonewall things and keep it from getting to that point, obviously. You might as well ask why the Nixon and Ford Administrations didn't investigate allegations of U.S. assistance in Operation Condor, or why the Kennedy Justice Department didn't investigate allegations of election fraud in the 1960 election.