Here's a Utah law firm offering advice on how to annul your marriage should you have found the man you married to be unable to have sex: https://www.isfma.com/law-and-order/when-ending-a-marriage-o...
Here's a review of case law in BC from the 2000s: https://disinherited.com/family-law-matters/annulment-for-no...
Scientifically, one cannot know if you're sterile until you've tried. There's no 'test' for sterility that truly works or that there hasn't been an exception too. Legally, once a marriage is fully consummated, it's more permanent than if it weren't. Historically, a marriage that was consummated could not be dissolved and was considered permanent at that point, so even if you later found out (usually after many years) that you couldn't have kids, the marriage would continue. Similar to how old people stay married.
I'm giving an historical view on marriage. Not saying how things should be. You seem incredulous at this view, but it was the prevailing view of marriage in Europe and the West for thousands of years.
I understand your position. On your point about why people think marriage is a right… I suspect this is because, at present, many rights are coupled with marriage - visitation rights at a hospital being the classic example.
Couples without children can adopt children, regardless of the gender of the parents.