Pregnancy doesn't happen right after you have sex — that's why it's possible to prevent pregnancy a few days after you do it. It’s all about timing.
Sperm can live inside your body for up to 6 days after sex, waiting for an egg to show up. If you ovulate during that time, the sperm can meet up with your egg and cause pregnancy. Morning-after pills work by temporarily stopping your ovary from releasing an egg. It’s kind of like pulling the emergency brake on ovulation.
Where you’re at in your menstrual cycle and how soon you take morning-after pills can affect how well they prevent pregnancy. Morning-after pills won’t work if your body has already started ovulating.