The body is constantly exposed to pathogens, all the time, in everything you eat, the air you breathe, everywhere. It is as if your laptop was downloading millions of random executables from every site you visit and hapilly running them (the analogy with Javascript and browser exploits just writes itself!)
Antibodies are in the metaphor both an allowlist AND a blacklist. Anything that isn't a well-known protein made by the body (allowed) is fair game for antibodies to bind to. You make quintillions of these that will bind to anything under the sun. Once they find a pathogen, it goes on the blacklist and more specific antibodies are made for it, that's adaptive immunity. There are many further layers and defenses on top of that, of course, but compared to infosec this is already much stricter filtering than a typical endpoint protection product.
It's easy to look at it and say hey we should lock down the cell membrane by adding randomly generated passwords and rotating them, that will improve security! But that's not realistic, a lot of simple things need to go through the cell membrane all the time.
That would be like requiring all living beings to show a passport before entering your country. Your intent is that you mostly care about catching criminals, but the border is mostly crossed by birds and small critters. The cell is the same, lots of things go in and out all the time, and they're too simple to carry any sort of identification. That's like requiring birds to have a passport.