$item is nowhere defined, you cannot just use a random variable anywhere without defining it first (in the header-nav, we are looping through a collection of pages and $item is defined as the value in that loop, in that case, a page object)
isOpen() is a page method, in the nav snippet from where you got that code, $item is a page object, but in the current case, we are just dealing with an array of tags, where the single tag ($tag) is just a string.
So to determine if a tag is active, we have to compare the $tag in the loop with the current tag parameter in the URL:
Unfortunately, the suggested line also causes the page to go offline. However, I found a former topic that helped solving the issue (sorry for missing that before).
What I did not communicate clearly enough though was that I want the selected tag to be styled differently. To achieve this, I replaced class="active" by class="current" and added css accordingly. Now everything works as I want it to: