Because they were in business offering a service to the public for money.
Just as the inn keeper who does not want to rent a room to unmarried couples. That has already been litigated.
If one does not wish to make wedding cakes for certain people then be a word of mouth not a walk in bakery.
The other option is don’t bake wedding cakes at all.