I tried in your MS Word Ribbon example and it does the same.
Add event handlers for SelectionChanged and/or SelectedIndexChanged.
If tab 1 is selected and I select tab 2...
.. first event fires indicating selectedIndex = 2
.. second fires indicating selectedIndex = 0
.. third fires indicating selectedIndex = 2
If tab 2 is selected and I select tab 2 again...
.. first event fires indicating selectedIndex = 0
.. second event fires indicating selectedIndex = 2