It’s a tiny bit convoluted, but you can just use a style class for this, too:
Set the duration appropriately, then add a stop at 49% with the same color as your 0% state.
Then add a stop at 50% (and 100%) with the alternate color.
The animation will take 1s to transition through all your steps - so half the time, it will be trying to transition from step 0 to step 49 - but since they’re the same, nothing will happen. Then, after 50% of 1s has elapsed, it switches to the 50% style (and the new background color). Then it tries to “transition” between that style and the 100% style - so as long as they’re the same, there will only be a single “transition” frame between animation loops.