A lot of drug purchasing things are codified. For example, Medicare is banned from negotiating drug pricing with manufactures. So even though they're buying billions of dollars worth of drugs in bulk, they're literally paying the retail price, which is just whatever the Pharma companies ask for.
In terms of why they're buying the branded version in the first place, not entirely sure what the exact situation is right now. I'm sure someone will write a great article on it in a few years though after all the money has already been siphoned off.