It's like asking why a Mercedes or a BMW cost more than a Honda. They all do the same thing, and increasingly over time, their differences become slimmer.
But guns like H&K and Sig really are built to a higher standard. A standard of design, materials and testing. Both of these brands have been selected by the most elite military personnel and are subjected to the most extreme and harsh environments with the full confidence that whether loaded with seawater, sand, mud or all of the above, they will always perform perfectly.
Building to these standards and, what is more costly, continuously testing against these standards are part of the cost.
Now, does the average civilian need any of these qualities? Not really. I don't tuck my USP in my wet suit when I go on a wall dive so it's quality, which we pay for when we buy one of them, is not really needed.
There actually may be other brands (Glock comes to mind) that can perform in these environments but for whatever reason, they are not chosen as often as H&K and Sig. Perhaps they're not as tough, perhaps Glock doesn't bother to test and prove their toughness.
Anyway, that's my take.
B