Some people already planned to get married.and accidentally become pregnant.
Some people plan to have a baby first, before marriage. Then get married later.
Some people never planed to get married OR get pregnant, but when a pregnancy happens they end up foolishly doing both.
Some people are in the middle of planning a wedding a year in advance and then find out their birth control method failed them but they still get married as planned, after the baby or while still pregnant.
Some girls accidentally get pregnant and the father just wants to do the right thing or they are pressured into getting married to give the child a supposed stable environment.
Those are the scenarios I can think of off of the top of my head.