Generic medicines must demonstrate that they deliver the active ingredient into the body in essentially the same way and amount as the original brand. Regulators in the US, UK, Canada and EU set strict equivalence requirements before a generic can be sold, so the clinical effect is expected to match.
A small number of patients are sensitive to differences in inactive ingredients, or use medicines with a very narrow safe range where even tiny variations matter, such as some thyroid, epilepsy or blood-thinning medicines. In those specific cases your doctor may prefer to keep you on one consistent product.
If you switch and feel the medicine is working differently or you have new side effects, do not just stop it. Talk to your pharmacist or doctor, who can review whether the generic is suitable or whether you need a particular brand.