Yeah, a declaration of optics and low value could be a red flag, but realistically, you just got a bit unlucky.
Packages also sometimes get flagged automatically due to sender/receiver names, origin location.
For lasers, they are usually marked as flashlights, and a $25 value, so no one really bat's an eye. Not to mention that on an x-ray machine, it would take someone knowledgeable to tell the two apart, and there are thousands of different designs.
Bottom line agents are mostly interested in genuinely/obviously/obvious dangerous stuff, some prohibited stuff, and drugs.
Another good argument for legalization... would actually make our borders quite a bit more secure if focus shifted to everything else, due to a lack of demand for drugs coming in.