Congratulations!!
You can only get pregnant from sex around your ovulation.
Ovulation takes place 12 to 16 days before your period (average 14 days). Sperm can live in your body for a few days and wait for your ovulation to happen.
The sex that got you pregnant happened around 13 to 18 days before your period was due to arrive.