It isn’t just about the letter of the law, it is also about judicial attitudes-two countries can have the same law on paper, but with radically different applications in practice, to the point that it isn’t really the same law.
Yes, in many US states, someone under 18 can legally marry with the permission of a judge. And if the applicant is a pregnant 17 year old who wishes to marry her 17 year old boyfriend so their child isn’t “born out of wedlock”, a lot of judges will say “yes”. But if the applicant is a father who says “I think my 12 year old daughter is old enough to get married, and I found her a husband I like”, no way in hell is any American judge approving that, even if the letter of the law says they could.
But in some other countries, there are judges who would be happy to give that marriage official permission.
I'm not from the US so excuse my ignorance, but if law says it's legal, how is it possible that the judge doesn't grant it? Wouldn't that make it illegal for the judge to do so?
The law usually says it can be done but needs permission from a judge. This is like saying that an after-school activity can be done for children but needs permission from the parent. That doesn't mean the parent must give permission.
Judges are way too busy to officiate most marriages in the US.
Basically any adult can officiate a marriage, then its just a matter of filing the right paperwork with the county clerk - that is what constitutes the legal/civil marriage in the US.
There was the famous case of the clerk in a county in Kentucky refusing to certify same-sex marriages a few years back.
There is also something called "common law" marriages where the state considers you married even if you didn't file the proper paperwork, but were co-habitating and especially if you had children. But this is a dying practice and only recognized by a few states / territories (ironically Washington D.C. is one of them ...)
The law isn't "child marriage is always legal" but "child marriage is allowed in specific cases with a judges consent" basically. They usually need to be given a reason to make an exception