What's the logic behind having kids outside marriage?

I absolutely don't mean this to be judgmental in any way and I'm totally asking out of curiosity and a little confusion.

It seems like lots of couples make the decision of having a baby before they're married (and I'm talking about planned pregnancies not accidental ones) and I don't understand why. If a couple isn't married, that means they aren't sure that they wanna spend the rest of their lives together (unless they don't believe in marriage-as far as I understand). So why would a couple bring children into the relationship if they aren't sure they wanna stay together to raise the children?

Again, I totally don't mean this to be judgemental. I just want to understand.

UPDATE :Thank you everyone who responded to this. I understand this better now. I think my confusion came from not realizing that a lot of couples are fully committed and have great and stable relationships but still choose to not get married for various reasons (family, finances, not believing in marriage, and other reasons). I thought there were only a few couples like this but seems like I was wrong.

Please feel free to keep commenting your stories and reasons so me and others can better understand having kids outside marriage.