Monitoring the outbound connections is what’s relevant to identify if you’ve been compromised and in some cases prevent it. A flaw in software exposed to the internet might allow remote code execution but what that code does most of the time is connect outbound to a C&C server on the Internet to download malware. If that’s detected and blocked, you avoid the malware download in the first place.
You can also sometimes be a victim of a supply chain attack which would render all of your preventative measures like VPN only access, Anubis, WAFs moot.