This is mostly caused by autostruts. Essentially you take a craft that has autostrut on it, and after a bit of use (especially where largeish forces are applied), itll end up a tad twisted and or have parts out of place by a little bit, and the ONLY way to fix that is either disable the autostruts or quicksave/quickload.
This is actually the main reason i pretty quickly gave up on autostruts, since any vessel that gets shot at or fires any powerful weapon would end up crooked and unable to fire straight on subsequent shots. With normal struts or no struts, the craft just wobbles back into its original position after recoil has done its thing, with autostrut it recoils and warps/bends and stays that way.
TLDR, avoid autostruts in anything but launch stages as they can be really screwy especially when used in large numbers.
I have alot of experience with weapons (lets face it, i play this game as if it was any other sci-fi combat game but with the ability to custom build your armor/weapons) so ill try my best to help you out. I cannot be certain what is wrong without a craft file, but here are a few tips i can give you with stock sepatron missiles.
The first thing you can do to make weapons fire more straight is to use spin stabilization. The idea is to have the sepatrons angled sideways by about 1 tick, and make sure to use radial symmetry so that the sepatrons are not making it fire sideways. This isnt essential, but it helps alot when your ship is moving slightly (its very hard to get a ship to be 100% stable using the stock SAS especially if its very heavy and low on reaction wheels).
The next best thing you can do is to avoid long stacks of weapons. While the compactness is very tempting, it is both a bad practice in the armor department (easier to degun a ship with less hardpoints and long stacks of missiles one after the other), and it makes the weapons less accurate. The issue is that the first few shots will wobble on the stack and make it more difficult to aim them, usually resulting in minor spread which is exasperated if the missiles are not spin stabilized.
Finally, make sure you do NOT use regular struts to attach weapons to teh ship. From my experience struts will 90% of the time result in the weapons veering off to the side when fired. If you absolutely must use struts to attach a wobbly stack to the craft, use the autostrut feature which doesnt seem to make missiles fly sideways as often.
Also worth mentioning is that you should be using radial symmetry when constructing sepatron missiles. It should be obvious as to why, but occasionally even i forget and end up with unuseable weapons that fly sideways when i accidentally used mirror symmetry.
Anyways, if these tips dont help, please upload your craft so i can take a look at it in more detail then the screenshots show.