The price that Medicaid pays for pharmaceuticals is based upon the price in the private market. When Medicaid prescriptions are only a small portion of the total market this works reasonably well at avoiding the twin problems of monopsony (Medicaid pushing prices so low that R&D incentives are curtailed, as has happened in the vaccine market) and monopoly (pharmaceutical firms jacking prices up above fair market value).
But in some areas, Medicaid accounts for a large fraction of the market. The Medicaid share for HIV drugs, for example, is more than 50% and in antipsychotics the Medicaid share is more than 75%! (I have cribbed from this paper by Mark Duggan.) In this situation it makes sense for pharmaceutical companies to raise prices – they lose customers in the private market but this is more than made up for by the increase in prices that they can charge to Medicaid. As a result, average prices for HIV and antipsychotic drugs are higher than for any other drug categories.
The Medicaid pricing formula can create a vicious spiral. Medicaid pricing causes prices to rise which pushes more people into Medicaid thereby shrinking the private market and increasing the incentive to raise prices yet further. To add insult to injury, high pharmaceutical prices are then said to demonstrate why we need more government involvement.