A logic issue was addressed with improved checks. This issue is fixed in macOS Big Sur 11.6.8, macOS Monterey 12.5, Security Update 2022-005 Catalina. An archive may be able to bypass Gatekeeper.
https://unit42.paloaltonetworks.com/gatekeeper-bypass-macos/
https://support.apple.com/en-us/HT213345