The companies agreed to sell most of their drugs to Medicaid at the prices they charge in European countries and to sell drugs directly to consumers through a planned TrumpRx website.