Yeah, weapon attachments only work on certain guns. They should have a small icon in the corner when you have a closer look at them (Where you see damage, energy cost etc). These icons match those that are on the attachments themselves e.g. miniguns will have small minigun icons and there is the alternate ammo attachment for the minigun which shares the same image. Same for shotguns and explosive ammunition.