I don't understand how the court came to the decision that a private homeowners association cannot bar access to non-residents.
Perhaps Caleb's Airplane can elaborate more, but evidently gated communities in Puerto Rico are different from what mainland Americans would picture as gated communities, and in fact are not just private homeowner's associations.
Rather than being private developments like a homeowners association that restrict access to private property, Puerto Rico allows neighborhoods to control access to the entire neighborhood, including public streets if the town votes for a plan of that type. Because they are approved by the local government, it's a public action and legally somewhat different than a gated community on private property. At least that's the basis for the court's decision.