Pharmacies often substitute a generic for a brand, or one generic for another, and for most medicines this causes no problem because the active ingredient and strength are the same. You can usually switch without any concern.
There are exceptions. Some medicines, such as certain thyroid, epilepsy, blood-thinning and transplant medicines, have a narrow margin between too little and too much. With these, doctors sometimes recommend sticking to the same brand or product to keep levels steady, and may write the prescription accordingly.
If you are unsure whether your medicine is one where consistency matters, ask your pharmacist before accepting a switch. And if you do switch and notice any change in how you feel or new side effects, report it to your healthcare professional.