If people who biologically can't have children or are too old to do so can still get married, why can't homosexuals?
Marriage is the relationship in which a man and a woman become one in a lifetime commitment. That is why their becoming conjugally—and complementarily—one is called “the marital act.” In contrast, the absence of complementarity in a same-sex couple is self-evident, beginning with their futile attempts at conjugal communion (CCC 2357-59). In short, with a same-sex couple, the two necessarily cannot become one, and therefore their sexual expressions are necessarily not love-giving (unitive), let alone life-giving (procreative). Nor would they make fit adoptive parents, even though they can certainly love children as a relative or family friend. But a sterile married couple would make fit parents, given that the wife can complementarily fulfill the role of mother and her husband the role of father.
Divine revelation affirms what we can discern by reason from the natural moral law. God made us in his image and likeness, male and female (Gen. 1:27-28). And those whom God calls to marriage become one flesh for life (Gen. 2:23-24), and God normally blesses them with children and draws them closer to each other in him, enabling those who can’t conceive to become good adoptive parents. Jesus reaffirms that marriage is between a man and a woman, and that it is a lifetime commitment (Matt. 19:1-12). Note that Jesus relaxed the Jewish disciplines regarding unclean foods (Mark 7:14-19) yet never relaxed the Jewish teachings against same-sex relations, let alone redefined marriage. Those morally impermissible practices were simply never on the table.
Homosexual relations have no hope of making the two participants one, let alone being a renewal of covenant love in an ongoing way (see Gen. 2:23-24). These acts are incapable for one to make a conjugal self-gift of himself or herself.
In comparison, when a wife becomes infertile because of age—or either spouse is infertile for reasons beyond their control during the wife’s normal childbearing years—the marital act is still a beautiful expression that renews and deepens the marital love of husband and wife. So we see that the love-giving aspect nourishes marital life even when a couple is sterile. Consequently, onanism and other forms of marital masturbation are sinful—a sin against the sixth commandment—because they prevent the total and mutual self-gift of husband and wife that conjugal love is designed to be and renew, including when a husband and wife are sterile (see CCC 2366-70; 1854-64).