§ 1001 is what it says it is: The general law covering false statements involving the federal government. In other words, § 1001 sets the default rule, which applies except when Congress establishes a specific rule covering a narrower set of cases. § 1001(b) is one of those specific rules covering a narrower set of cases. § 1001(b) does not say "it is ok to lie to a judge.” It says "lying to a judge is not covered by the general rule against making false statements to federal officials established in § 1001." Lying to a judge is not covered by § 1001 because it is covered elsewhere.
Lying to a judge is called perjury. Broadly speaking, the difference between making a false statement, covered by Chapter 47 Fraud & False Statements, § 1001 - § 1040, and perjury, covered by Chapter 79 Perjury, § 1621-1623, is that perjury only applies to people who lie under oath.
Perjury is not the only exception to the general rule against making false statements to federal officials laid out in § 1001. The rest of Chapter 47 Frauds and False Statements lists 38 other exceptions to the general rule in § 1001. These range from lying about highway projects (§ 1020) to lying to get major disaster or emergency relief (§ 1040). Each gives more detail about who breaks the law by doing what, and what punishments they face.
These sorts of exceptions to broad legal rules are quite common. They are used when law makers decide that “one size does not fit all,” that how bad the crime is depends on the specific circumstances. For example, there is no general law against killing. Instead, there are laws that cover killing people on purpose, accidentally, while defending yourself, while committing a crime, while working for the government, while driving a car, and so on. These distinctions reflect “our” judgment that how bad it is to kill someone depends on the circumstances.
As a matter of fact, perjury is a much older crime than making a false statement. Perjury was outlawed by the first Congress in the first federal criminal code passed in 1790. The earliest version of § 1001 outlawing false statements was passed in 1863. This version only applied to: a) servicemembers, who b) made claims against the government. 70 years later, in 1934, § 1001 was expanded to cover: a) anyone, in b) “any matter within the jurisdiction of any department or agency of the United States.” In other words, after 1934, § 1001 only applied to lies involving the Executive, not Congress or the courts. It was only 20 some years ago, in 1996, that § 1001 was extended to cover “any matter within the jurisdiction of the executive, legislative, or judicial branch.”