I think it is because pregnancy can last for 9 months.
For every month there are estimated 4 weeks.
9 months x 4 weeks = 36 weeks
Maybe 40 weeks is the estimated number of weeks pregnancy can last.
Note: 36 weeks is just estimated. I'm sure it is not exact, it is insufficient.