Both agencies and contractors employee people with the skillsets needed to write these kinds of things. While there are a large number of incompetent government employees and contractors, there are also a small number of frighteningly talented developers working in this area.
i sometimes wish that there's some sort of darwinian selection system that could be put in place, in order to improve the overall efficiency and productivity of companies...but then again, i m writing this from my work terminal...