Enjoining good and forbidding evil is obligatory when it's conditions are fulfilled. The conditions include: 1. Knowing definitely that the specific act is good or bad in Islamic rules. If you are not sure, then it is not obligatory on you.
2. Having a reasonable possibility that you can achieve any impact on them. If you are sure that the sinners will never listen to you, it will not be obligatory on you.
3. There should be no danger on you or other believers if you enjoin good or forbid evil.. If you have a reasonable possibility of danger, then it will not be obligatory on you.
'Enjoining good and forbidding evil is a great deed of obedience of Allah (SWT). It is the act of the prophets and Infallible Imams. It help the person himself to to do good and avoid evil.
Wassalam.