Was this (allegedly gay) marriage in a Catholic Church valid? The Spanish newspaper El Pais wrote an article the other day (with an awful clickbait, I must say), where it told the story of two women married by the Catholic Church in 1901. The story goes that they were married by a local priest, with one of the woman disguised as a man (as one of her dead cousins, in fact). The priest did not know the situation, and hence the marriage received official approval. The article claimed then that this is "the first (and only) official gay marriage in the Catholic Church" (title of the clickbait), and which has yet not been annuled.

Two things come to my mind. First, the marriage act probably stated the name of the (dead) cousin, and hence, the two women were actually never married (i.e. they couldn't prove it, since they didn't have a certificate to the name of both women). Second, as one of the spouses was dead, the marriage was invalid. Thus, there was never a valid marriage anyway, and thus there is nothing to annul. Is this the case?
Indeed. It's not possible for anyone but a man and woman of age to marry themselves (the sacrament of marriage is actually contracted by the couple, technically speaking, the priest being only a witness). Anything else is not the sacrament of marriage but something else: therefore they not only were not married, but could not have been married. One does not need an annulment to prove this, only proof that both parties are female, or both parties are male.
@K-HB found a canon in the Code of Canon Law which contains a definition of marriage:

Code of Canon Law
Can. 1055 §1 The marriage covenant, by which a man and a woman establish between themselves a partnership of their whole life, and which of its own very nature is ordered to the well-being of the spouses and to the procreation and upbringing of children, has, between the baptised, been raised by Christ the Lord to the dignity of a sacrament.
...

It goes on to define what matrimonial consent is, too:

Can. 1057 §1 A marriage is brought into being by the lawfully manifested consent of persons who are legally capable. This consent cannot be supplied by any human power.
§2 Matrimonial consent is an act of will by which a man and a woman by an irrevocable covenant mutually give and accept one another for the purpose of establishing a marriage.

And for something from the catechetical realm, here is a portion from Ludwig Ott's Fundamentals of Catholic Dogma on Matrimony (Book IV, Section VII, 1):

Christian marriage is that Sacrament in which two marriageable people of different sexes associate in an undivided life-communion by mutual agreement for the generation and education of offspring, and in which they receive grace for the fulfillment of the special duties of their state.

The Catechism of the Council of Trent (or, the Roman Catechism) gives a definition of marriage:

The conjugal union of man and woman, contracted between two qualified persons, which obliges them to live together throughout life

In his famous Encyclical on Matrimony, Arcanum (a highly recommended read), Pope Leo XIII wrote (Arcanum, 5):

... And this union of man and woman, that it might answer more fittingly to the infinitely wise counsels of God, even from the beginning manifested chiefly two most excellent properties - deeply sealed, as it were, and signed upon it-namely, unity and perpetuity. From the Gospel we see clearly that this doctrine was declared and openly confirmed by the divine authority of Jesus Christ. He bore witness to the Jews and to His Apostles that marriage, from its institution, should exist between two only, that is, between one man and one woman; that of two they are made, so to say, one flesh; and that the marriage bond is by the will of God so closely and strongly made fast that no man may dissolve it or render it asunder. &quot;For this cause shall a man leave father and mother, and shall cleave to his wife, and they two shall be in one flesh. Therefore now they are not two, but one flesh. What, therefore, God hath joined together, let no man put asunder.&quot;

Many more sources could be adduced, but to put it more simply: the Church knows of no sacrament intended for or concerning the union of two of the same sex.