Article 85.4 from the Law 29/2006 about warranties and rational use of medicines and health products (Spain):
When the prescription is made by active ingredient, the pharmacist will dispense the lowest priced medicine from its homogeneous group and, in the case of equality, the corresponding generic medicine or biosimilar medicine.
Or even sometimes just change the indication, like when Eli-Lilly re-patented Prozac as Sarafem because it could be used to treat premenstrual dysphoric disorder (PMDD).
Same drug, but they could keep it as brand-name for some patients.
We do not benefit from the brand name. Pharma does. Sometimes the PBMs (middle men between insurance company and pharmacy) paying for it do as they get kickbacks. Sometimes they pay below the cost of the drug to the pharmacy despite them knowing perfectly well no pharmacy can get drugs that cheap. Branded drugs are not good for pharmacies.
Here, you get prescribed the non generic but the government subsidies only apply to the cheapest version available at a specific pharmacy.
So if a pharmacy only has the non generic, that's the one you get heavily discontinued (or free, depending on how much you already spent that year on prescription drugs), but if they have some cheaper generic version the subsidies only cover that one (you can pay the difference and get the non generic if you want).
So it's pretty rare that you actually get the non generic drug unless that pharmacy just happens to be out, or if your drugs are still under patent.
I am pretty sure our government also negotiates prescription drug prices, which keeps prices down (I guess mostly for them, since it's so heavily subsidized.)
It's the insurance companies (Specifically the Pharmacy Benefit Managers) who generally mandate the brand name over the generics. Prescribers might write the brand name on the prescription, but most (if not all) states have laws that allow automatic substitution to the generic.
Pharmacists (Who generally do not do any prescribing*) and Prescribers don't get any benefits from prescribing brand names. If they do, they're likely breaking anti-kickback laws.
(*There are clinics and states that allow pharmacists to prescribe medications. In Oregon for example, retail pharmacists can prescribe birth control. Or a clinic may have pharmacists reviewing and adjusting a patient's warfarin therapy)