The behavior you're seeing is correct and there's a reason that your program isn't working and the one by @kandennti is. The reason is "context". Because you're getting the component and then getting the occurrence visibility you're getting the visibility in the context of the component. In kandennti's program he's using the allOccurrences property to get all of the occurrences relative to the root component, which means they're all returned in context of the assembly.
Here's an example that hopefully helps to better illustrate this concept. Visibility of occurrences is managed at the top level of an assembly. You can see in the example below that it has to be this way for it work correctly. Notice that there are three instances of the Component5 subassembly. I'm able to set the visibility of the occurrences in each one of those instances independently. If we look at Component5 by itself, it contains Component6 and Component7. But in the context of the entire assembly there are three Component6 and three Component7 and each one of those can be controlled independently. Even though there is actually only one real Component5 component, there are three occurrences in the assembly that reference that component. In the context of the top assembly these are three unique occurrences and can support some unique settings like visibility, color, and position. To be able to reference something in the top assembly that exists somewhere else, you use a "proxy" object. A proxy is an object that is representing an object in a different context. You can read more about this concept in the API help.

Here's the code that generates the output above. It's not using allOccurrences, but is traversing the assembly as you did but instead of going to the Component it's using childOccurences to get the occurrences from an occurrence. This returns proxies of the occurrences so they're in the context of the top-level assembly. It uses a recursive function to be able to iterate over an entire assembly regardless of the depth of the levels.
def run(context):
ui = None
try:
_app = adsk.core.Application.get()
ui = _app.userInterface
des = adsk.fusion.Design.cast(_app.activeProduct)
root = des.rootComponent
getOccurrenceVisibility(root.occurrences, 0)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def getOccurrenceVisibility(occs, level):
spaces = ''.ljust(level*4)
occ = adsk.fusion.Occurrence.cast(None)
for occ in occs:
print(spaces + occ.name + ':' + str(occ.isVisible))
getOccurrenceVisibility(occ.childOccurrences, level+1)
---------------------------------------------------------------
Brian EkinsInventor and Fusion 360 API Expert
Website/Blog:
https://EkinsSolutions.com