Wrong way round.
You didn't upload any macro -- you posted a screenshot. That limits how people can help since they can't see any options you may have set in actions, can't see what may have happened before the bit you screenshot, and so on.
And the easier you make it for people to help the more help you'll get -- why is someone going to spend 5 minutes recreating your screenshotted macro in KM so they can test when the next thread has a macro they can download and run?
So, ideally, you'd upload a minimum viable demo that illustrates the issue.
How do you know?
I'm not saying you're wrong, but I see the opposite. It may be because we have different setups, it may be because we are testing differently.
If you are testing by running the complete macro with different things selected, look closely at that second "If" action's condition -- the .* at the end means it will not match only "Macro" but also "Macro Group"... I'm betting that's why you think you're non-regex version of the third "If" is working, even though it isn't.
In a further twist -- this macro is really unreliable for me, often requiring me to actually open the Editor's "View" menu to get the correct results after changing selection between Action, Macro, and Group. That may be my clunky old hardware, or something you may not see in "real world" use, so YMMV.
Assuming this -- enabling and enabling KM items by keystroke -- is something you actually want to do rather than a fun exercise in menu testing and manipulation, you'll find AppleScript or JXA to be a much more reliable method (for which you can thank @peternlewis for including a brilliant AppleScript dictionary).
Here's the script which follows what I think is the Editor's rule of "if any item is disabled then enable them all, if all items are enabled then disable them":
set newEnabledState to false
tell application "Keyboard Maestro"
set theList to (get selection)
if theList is {} then
beep
else
repeat with eachItem in theList
if enabled of eachItem is false then set newEnabledState to true
exit repeat
end repeat
repeat with eachItem in theList
set enabled of eachItem to newEnabledState
end repeat
set selection to theList
end if
end tell
If nothing is selected you'll get a "beep". Otherwise each item in the selection is tested -- as soon as one is found to be disabled we flip newEnabledState from false to true and exit the loop. We then loop through the selection again, this time setting each item's enabled to newEnabledState. The final set selection is there because, for me anyway, running this with Actions selected clears the selection and I want them to remain selected.
And as a macro:
KM - Toggle - Enable - Disable → Actions -Macros - Macro groups (AS version).kmmacros (2.8 KB)