Married teenagers

I'm so confused, how could a teenager get married? Don't you have to be 18? I've seen so many girls on here who are 16/17 and married. I don't understand it. I am 17 and have been with my boyfriend for 2 years and as much as I want to marry him, we aren't planning to get married until we are in our twenties. How could you even afford a wedding at 17?!