For sheild bearers, it's so they can be treated as military. If they didn't have guns, they would be treated as non military, which would cause some odd behaviour for both the humans and the AI. Though the human odd behaviour could partially worked around by making the shield bearers "brave" (that is, use similar selection behaviour as brave scout starships) it wouldn't fix all unit management quirks, and it wouldn't fix the AIs treatment if them.
For the wormhole guard posts/passive guard posts/etc. thing, it's mostly a "hack" to ensure that AI ships on stand-by mode will "wake up", as they are keyed to wake up when the thing they are guarding fires its weapon at something within the "guarding range", which is actually smaller than the range of some guard posts, strangely. (The other primary way to wake up a group of defenders is to shoot at or destroy any of the defenders or what they are defending) This is why sometimes you will be able to sometimes "sneak up" on a command station without its defenders waking up, as there is nothing of the AIs to fire to trigger the group to check whether they should wake up, and human ships by default won't auto-target "non-alerted" AI stuff to prevent things like long-ranged ships from waking up the whole planet by being too eager to shoot (and thus free) stuff.