First of all, in the US, or more exactly, in many US states, Gender and sexual orientation are protected categories, while political belief is usually not. Moreover, gender at least is something that a person cannot change, and many people now believe that the same is true of sexual orientation as it is of "race", ethnicity, national origin, and similar attributes. This is held by many to make distinctions on the basis of those attributes particularly undesirable and unfair.
Secondly, such discrimination is often prohibited only in "places of public accommodation". The US Federal The Civil Rights Act of 1964: Title II (section 201 (B) ) defines this as:
(b) Each of the following establishments which serves the public is a place of public accommodation within the meaning of this title if its operations affect commerce, or if discrimination or segregation by it is supported by State action:
(1) any inn, hotel, motel, or other establishment which provides lodging to transient guests, other than an establishment located within a building which contains not more than five rooms for rent or hire and which is actually occupied by the proprietor of such establishment as his residence;
(2) any restaurant, cafeteria, lunchroom, lunch counter, soda fountain, or other facility principally engaged in selling food for consumption on the premises, including, but not limited to, any such facility located on the premises of any retail establishment; or any gasoline station;
(3) any motion picture house, theater, concert hall, sports arena, stadium or other place of exhibition or entertainment; and
(4) any establishment
(A)(i) which is physically located within the premises of any establishment otherwise covered by this subsection, or
(ii) within the premises of which is physically located any such covered establishment, and
(B) which holds itself out as serving patrons of such covered establishment.
Many state laws also reference this definition.
Sections 202 and 203 of this same federal law provide that:
SEC. 202. All persons shall be entitled to be free, at any establishment or place, from discrimination or segregation of any kind on the ground of race, color, religion, or national origin, if such discrimination or segregation is or purports to be required by any law, statute, ordinance, regulation, rule, or order of a State or any agency or political subdivision thereof.
SEC. 203. No person shall (a) withhold, deny, or attempt to withhold or deny, or deprive or attempt to deprive, any person of any right or privilege secured by section 201 or 202, or (b) intimidate, threaten, or coerce, or attempt to intimidate, threaten, or coerce any person with the purpose of interfering with any right or privilege secured by section 201 or 202, or (c) punish or attempt to punish any person for exercising or attempting to exercise any right or privilege secured by section 201 or 202.
The Federal ADA prohibits discrimination on grounds of handicap or disability, and mandates access for people with various disabilities.
Many state laws prohibit discrimination on various grounds in various circumstances -- both the set of protected classes and the circumstances in which such prohibitions apply vary significantly from state to state. For example, sexual orientation is protected in some states but not others.
The laws in non-US jurisdictions will vary even more.
But to the best of my knowledge, political party or viewpoint is not usually one of the protected classes. In general, discrimination is only prohibited where there is a specific law forbidding it. In the absence of such a law, both individuals and businesses may engage in discrimination if they so choose.
That said, I have heard of very few cases where businesses, particularly businesses run by sizable companies, refuse to serve adherents of one political party or viewpoint.
By the way, as I understand it, the Masterpiece Cakeshop case has still not had a final ruling on the merits. A court held that the commission proceedings failed to provide proper Due process in several respects, and sent the case back for further proceedings. There are some specific aspects of that case which make it a bit different from the classic discrimination case, and it is not at all clear what the final ruling will be..