One way to look at why a man and woman who are sterile can get married, even in the Church is this: Marriage as a sacrament does not depend upon whether the couple can have a child. That is not the basis of Christian (Catholic) marriage. Marriage is the mutual gift of man and woman to each other (in Christ, if a Christian marriage). The basis is if they can perform the marital act of union - ie intercourse, where they become “one flesh” by the mutual gift of themselves to the other.
The couple of course must not attempt to frustrate the fruit of this union by contraception or abortion, but these do not invalidate the marriage in and of themselves, except as they would expicitly violate the marriage vows. An example of that would be if a wife or husband insisted on using contraception every time the married couple united, such that the intent was for the married couple to never have children.
Homosexual sexual relations cannot be mutual self-gift (not to get too graphic). Neither can someone who is definitively and permanently impotent or who is underage (presently defined in Canon Law as under age 16 for men and under age 14 for women).
Edited to add: A couple who between whom one had been intentionally sterilized previously and wished to marry should seek spiritual advice from a trusted priest.
May God bless you.