You are disabling inheritance on every folder in the path. Each subfolder will have its own set of ACLs, which will potentially be different to the ACL on its parent.
You then modify the ACL on the root directory. Since you've disabled inheritance, this change won't apply to the subfolders. You would need to loop through every subfolder and update its ACL to match.
It sounds like you actually want to
enable inheritance, so that all subfolders have the same ACL as the root. To do that, use:
icacls $folder /reset /t /c /l /q
icacls | Microsoft Docs[
^]