Part of what you say is true, but part of it is paying for all the acceptance testing, meeting the .mil spec EXACTLY, all the paper work etc. And the salaries of all the people who do that work.
Stuff like the cheap Chinese BSA red-dot scope on top is LOL-worthy, but it's not quite as simple as buying an assembly, having the engineer design the housing and mating it to an M-16/M4 grip, and having the machinist turn it out, and then an electronics tech assemble it all.
I work in Aerospace/Defense Quality Assurance tracking, and dealing with the .gov and .mil is incredibly involved even when it runs "smoothly".
People will roll out the old tropes of the $400 hammer. Well really that $400 hammer was a beryllium/copper alloy designed to not spark EVER when being used to wail on a stuck pipes, valves, or hatches, when rocket fuel was leaking in an emergency. And the famous $100 toilet seat was for a submarine, that had to be designed to be absolutely quiet, if a sailor were to drop it, so it wouldn't clack on the bowl and give away their position to Soviet Sonar.
So it's possible these laser dazzlers were rip-offs, but even if they were, they weren't as much of one as you might think.
Assuming it has mil spec everything and has been ruggedized it might cost $2K for the system itself, the rest goes to all the administrative stuff that has to happen for each unit to comply with all the damn regs and each units share of the R&D and certification costs.
Its just like equipment for an aircraft ... you can get a non-TSO'd radio for a homebuilt aircraft for dirt cheap, but as soon as you want to install it in a certified aircraft you will pay a lot more for the exact same unit just because of all the paperwork and compliance (chain of custody, part sources, QC etc ...) required for a TSO'd installation.
[TSO = Technical Standard Order]