We're told the Dicastery for the Doctrine of the Faith of the One Holy Catholic and Apostolic Church has now reaffirmed that the Church forbids its members from joining the Freemasons, and that for them to become Masons is a "grave sin." This has been the Church's position regarding Freemasonry for centuries, since Freemasonry was founded in the 18th century. The reaffirmation was approved by the Pontifex Maximus himself. Interestingly, this continued condemnation of Freemasonry was issued contemporaneously with a determination by the Dicastery that transgender people may be baptized, may be godparents and may serve as witnesses at a wedding. Better transgender than Mason, it seems.
The Church's prohibition of membership in the Masons is interesting in several respects. Because both institutions prominently feature men (for the most part) dressed up in silly costumes, uttering pretentious phrases and performing peculiar rituals, one would think that they would have much in common. It appears that this was the opinion of Joseph Keppler, who drew the cartoon gracing the top of this post for Puck magazine in 1884. The cartoon is called "Two of the Same Kind" and features absurdly dressed Catholic clergy, one of whom seems to be a bishop or perhaps a pope, in battle with absurdly dressed Freemasons.
Perhaps their similarity is the basis for the conflict. They're rivals, in a sense. We humans have a taste for gaudy, garish costumes and impressive ritual, particularly in matters of religion. The Church's condemnation of Masonry appears founded on the belief that Masonry is a religion. There's some basis for this belief, according to the sometimes invaluable Internet. I know very little about the Freemasons, but it seems that they extol a supreme being they call the "Divine Architect" (they're supposed to be the successors of medieval masons, after all), and see themselves as servants of that being in the pursuit of a divine plan of sorts, or at least are pleased to say they are in their rituals. One of the reason past popes have condemned it is that they've considered it to espouse a religion of "naturalism" as opposed, it seems to "supernaturalism." That would be a point in its favor to some.
They have a fairly complicated system of initiation into several levels of Masonry, regarding which they're sworn to secrecy. This is similar to the practice of the ancient mystery cults, from which some say they're also derived or intend to mimic.
What distinguishes Freemasonry from modern religions, particularly those of the Abrahamic tradition, is the fact that it welcomes members of any other religion into its fold. This may make it particularly dangerous from the perspective of the Church. At least according to Freemasonry, Catholics, Protestants, Jews, Muslims and others are free to become Masons. There's no need for an initiate to disavow the religion in which they were born or have practiced in order to be a Mason. Thus the need for the Church to affirmatively forbid Catholics from joining the Masons.
The Church may also see danger in the fact that membership in the Freemasons is said to be beneficial to its members in various secular ways. It may satisfy the religious yearnings of those who are deists and others, but by all accounts does satisfy the ambition of those hoping to make their way in business or become wealthy. Masons are said to take care of each other, to grant each other favor or favors in life. A religion which isn't at all unworldly, then. Masons may have a reward in heaven because of their beliefs, but in the meantime will be rewarded in this life by other Masons.
It's not all that surprising, then, that the Church persists in condemning such an attractive religion.