That is a problem with your use of raycasting, because SMGs spray primarily due to the fact that they lob smaller masses at reduced speed. Then, it gets worse due to the movement of the barrel.
So, you can do one of several things:
You can slightly offset the origin of the bullets.
You can offset the endpoint by a small amount.
You could add a small angle to that of the barrel.
Personally, I would opt for option 3, since it simulates the barrel moving, and you could just make it worse the longer the trigger is held.