Emergency contraceptive pill or the morning after pill is a backup for when the original contraception used fails. It prevents pregnancy when one has had unprotected sex or the contraception used fails. The pill has to be taken within 72 hrs of having unprotected sex, in order for it to be effective.
Sources:
https://www.nhs.uk/conditions/contraception/emergency-contraception/
https://my.clevelandclinic.org/health/drugs/15653-emergency-contraception
https://www.webmd.com/sex/birth-control/plan-b