My theory:
A giant supercomputer is fed the current body of US law, including the Tax Code, and given several “keyword”/parameters. It churns and burns, taking sniplets and phrases from all over the law and assembling them together, and out pops a new, multi-hundred/-thousand page bill for Congress to sign.
This is why the only way to find out what is in the bill is to pass it and see what happens.
[/cynic]
I’m more partial to the infinite number of monkeys on an infinite number of typewriters theory myself. The reason that the laws are coming up with are so flawed is because of truncation errors due to the fact they were unable to obtain an infinite number of either monkeys or typewriters.