A baby is not considered to be born out of wedlock if the parents get married while the mom is still pregnant since the parents are legally married. Kids born from legally married parents are considered to be legit kids as per the law.
As long as the patents are wed before the baby is born it is not considered to be born out of wedlock. Long ago when this saying originated the date of the child's birth, not conception, was the date that was important. Born out of wedlock meant the marriage happened after the baby was born. The baby was born outside of marriage, or wedlock. Back then that carried quite a negative stigma - for mother and child.