None of us want patents, and the whole system is absurd. But at one time, it was considered prestigious to be named on a patent. And prestige is a powerful force. Part of the burden of working at a secret agency is that your work is secret.
E.g. This employee will be able to take credit for this work after they leave: http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO2&Sect2=H...
(Better not try to convert any programs that use loops into a program without loops.)
So here, the patent examiner is doing what you are suggesting. He is citing a prior art and while doing so, they have to make the patent available for public.
Edit: Literally the first two paragraphs of wikipedia: https://en.wikipedia.org/wiki/Prior_art