What you're referring to is the ability of a pharmacist to substitute one drug for another, if for instance it wasn't on your insurance's formulary (list of drugs they'll pay for). Drug A may be slightly different than Drug B, but the Drug B your insurance will pay for. Drug B might also _just happen to be_ a generic (because the pharmacist is trying to get your the best deal for your money). There's guidelines from the FDA, DEA, the state insurance commissioner, and state laws the pharmacists must be aware of so it varies greatly between states on what they're allowed to do. Made for a fun rules engine to implement in software.
Doctors can mark a prescription as DAW (Dispense As Written) which then the pharmacist can make 0 substitutions. Insurance companies aren't usually a fan of said doctors.
Sometimes the FDA certifies a dosage of a generic based on a different dosage. This caused a problem not long ago when the dosage they assumed was fine didn't dissolve right, hence the absorbed dosage varied and was sometimes way too low. To add insult to injury, it was a psychotropic drug, so everyone assumed patients complaining were "just imagining things" for a long time.
I've had to use transdermal medication (patches) before, and one of the inactive ingredients that changes is the adhesive, I've noticed that the "brand name" version didn't cause skin breakouts, and the generic did.
If I'm not mistaken, the formulation could be wildly different as long as they match kinetics, yield, and safety profiles set by the FDA, and an individual may have some issue with one formulation over another.