Change state of device without automation consequences

I have three switches (A, B, C) that I control with Home Assisstant and I want the following logic:
A -> ON leads to B -> ON
B -> ON leads to A -> ON
C -> ON leads to A -> ON (but leave B alone)
A -> OFF leads to B,C -> OFF

The only tricky automation is the third one. The problem is that when I turn C on, A is turned on which leads to the first automation running and turning B on. Is there a way to change a device state without leading to further automation running?