If a civilization had the technology to create wormholes for travel, what would stop them from using this technology to open wormholes right above their targets and launching a weapon through it? If they did this, it would basically be impossible to counter the weapon, because there would be no warning, and not even a visible projectile until the end of its trajectory. Basically, what rules should exist to prevent this in my plot? If a civilization has the technology to use portals for travel with reasonable levels of precision, then it seems inevitable that someone would weaponize this technology. So why choose to send a weapon in the form of a gun-ship instead of a warhead or some other destructive projectile? What laws of physics would explain why this technology is used for ships but not smaller weapons by themselves? Is there some limitation to wormholes that could explain this? What about wormholes would only allow ships to use them for travel and not weapons?
It's really obvious when a wormhole opens. There's a detectable circle several AU wide for 30 minutes before one opens.
In addition, any energy that is applied to that area is transmitted back to the wormhole generator.
If you see an unexpected wormhole opening up right next to your planet, you just nuke it. Whoever tried to open it had it coming.
This means that when selecting a wormhole destination for a weapon, it's a tradeoff between vulnerability and distance from target. If you can discover when an expected, 'friendly' wormhole is going to open next to your enemy's planet though, you have a chance of faking friendliness and achieving complete strategic surprise!
The process to create a Wormhole is (relatively) time consuming and delicate
So, let's say to create an end-point for a Wormhole takes 24 hours and due to the incredibly complex nature of the Physics involved, this process is very easy to disrupt, either deliberately or just 'Stuff Happens because space' way.
Now, for interstellar travel and trade - 24 hours and a controlled environment to setup an entry and exit point (when the alternative could be millenia of travel at sub-light speed) is very clearly worth the wait and the time to properly setup the Wormhole for commerce.
However, should there be nefarious intentions - you've got plenty of warning (24 hours - or however long your story requires) and the targetted group has the ability to disrupt this process - making it so difficult for a Military context (where surprise and speed of action are generally key).
In addition, if the Wormholes are stable once created - you could even have a scenario where there is in effect a border guard type force or other port authority that has the authority (and the means) to prevent the Wormholes being used for a Military context.
If either of those aren't to your fancy - you could look at Commercial GPS and how there are certain limitations to prevent the Commercial GPS network being used in a Military context, by looking at the differences (Speed, size etc.) of the vessels that would be using the Wormhole and limiting entry based on something that would only exist on a Military vessel.
Because gravity interferes with wormhole formation.
Most wormholes are formed either in specialized portal zones with artificially flattened spacetime or outside of solar systems. If armies could use portals for warfare they would, but the technology just doesn't work.
Of course, there may be rumours about precursor technology that can do it, but for the galaxy in general, it can't be used for warfare.
Most respondents jumped to the conclusion that you're looking for reasons why wormholes wouldn't be used as weapons. I'm going to jump to the conclusion that you're looking for a confirmation that anyone with this technology would, indeed, use them as weapons.
I'm assuming that your use of the internal-consistency tag means you want your idea to be substantiated. Please keep in mind that, normally, the purpose of that tag is for you to tell us the rules of your world and provide a circumstance that uses or is intended to obey those rules for us to judge whether or not you've created consistent rules and/or you are using your rules consistently.
If human history has proven anything, it's that every invention ever created or discovered has been weaponized. This includes everything from language to golf balls (if you haven't been on the receiving end of an angry golfer...).
Absolutely, wormholes would be weaponized. Nuclear power was weaponized. Gunpowder was weaponized. Arsenic was weaponized. Water has been weaponized. Social Media has been weaponized. Humans are remarkably good at using anything and everything at our disposal to get back at someone we think has maligned us — real or imaginary.
However, godlike weapons are as boring as godlike characters.
We occasionally get questions of the form, "how do I defeat my godlike character?" The answer is always the same: your character can't be godlike, introduce a weakness. You're in the same boat. One cannot open anything instantly without having access to, basically, infinite power. Wormholes would take time to open (if they could be opened remotely at all...). When they do open, they have the potential of causing massive climatic disturbances due to atmospheric pressure differences, gravitational differences, and the energy differences between the two termini of the wormhole (both openings are in motion, and that's a really big deal).
So, the situation isn't quite as dire as you suggest. But that's where you as the worldbuilder come in. Because (insofar as humanity knows) wormholes aren't real, therefore you have the privilege of defining the rules of your wormholes so they meet the needs of your stories.
And this is an important point. Wormholes aren't real... yet. Today they are nothing more than an interesting mathematical exercise. We've never seen one. We've never measured, tested, or experimented on one. We certainly haven't created one. Keep in mind that just because people talk about them all the time, that doesn't make them real. Dark Matter is in the same boat. We've never seen it, never measured it, can't prove that it exists. It just happens to solve some nasty problems with measured gravitational effects — but it's just as likely that it's our mathematical models that are wrong. Only time will tell. Finding some would solve the debate. Finding a wormhole would solve the previous debate. My point? Don't fall into the trap of the Religion of Science (aka, believing that everything that's presented logically and matter-of-factly must be real). Build your world the way you want it to be, because if you're trying to be as "scientifically accurate as possible," you might discover that in a few instances, physicists are kinda faking it — in an outrageous and incredibly fun way, which is their job, if you think about it.
You could rethink the way your portals work and make them not just be instantaneous straightforward doorways from point A to B. For example, maybe the route between them needs to be navigated and it is somehow difficult for a computer or artificial intelligence to do. Or maybe, the technology simply does not exist yet for autonomous navigation. Cruise missiles did not exist for a long time because of this.
Or the requirement could be imposed that the wormhole generator must pass through the wormhole to keep it stable en route. That would mean that even if the wormhole created could be shared, The result would be that any weapon sent through the wormhole would necessitate sacrificing the rare or expensive drive or require the drive to disengage at the destination and be recovered (which is probably not desirable or even possible in some cases such as if it opened onto a planet). Then you just make the wormhole generator requires rare materials, or simply be too expensive to sacrifice.
Social pressure. It's just Not Done--not by anyone civilized, anyway!
Otherwise... every setting I know of that features that kind of wormhole technology--Schlock Mercenary, Farscape, Star Trek, etc.--absolutely does use it for uncounterable weapons, which are controlled only by keeping the technology itself secret.
No Hollywood wormholes
Wormholes in reality probably wouldn't work the way they do in the movies. You wouldn't "open" one to a distant location. Rather, they'd be created side-by-side in pairs at very small scales, like particle pairs in quantum mechanics. And through much labor they might be "inflated" to macroscopic sizes by throwing small amounts of mass into them.
They might well be used as weapons but not in the way you think. It's suspected that collapsing wormholes may release ~70% of their mass-energy in gamma rays, depending on how (or if) the metric is coupled with the EM field. Even for kilogram-scale wormholes, that's super high-yield nuke territory. And if one goes both go. So, really, it's two nukes.
To get a wormhole to the enemy planet, you have to fly it there. Through all the intervening space, like transporting any regular object. This leaves open the possibility of the enemy detecting the approaching wormhole and destroying it. Or sending a wholesome, thermonuclear surprise your way instead. It's a two-way street, after all.