Hello sushant,
see below is the difference between before and after trigger.
BEFORE trigger
BEFORE triggers are usually used when validation needs to take place before accepting the change. They run before any change is made to the database.
BEFORE trigger
AFTER triggers are usually used when information needs to be updated in a separate table due to a change.
They run after changes have been made to the database (not necessarily committed).
Generally we go for Before event if there is something needs to be validated before the actual data is commited to database.
For example :
Let suppose you want to Insert new Account, but before the date is commited to database you want to validate if the Billing city is not null, if Null you will throw error and or else you will Insert record.
And in case of After, once the record is inserted/ Updated or Deleted, based on some condition you want to do some process.
For example:
Once the record is Inserted you want to send mail to update some filed on object “XYZ”.