We're talking about marginal costs, not development costs. So the cost to invent a component is already out of the equation. The high production cost of something like Hubble comes from testing and validation more than materials or fabrication.
The failure modes for something big in space can be extremely dangerous. Even a tiny "cheap" cubesat requires a lot of relatively expensive testing so there's a reasonable assurance it won't fail in some catastrophic fashion and destroy the entire rocket.
Testing space hardware is additionally difficult because you can only just approximate the hardware's operating environment on the ground. Space hardware also can't be easily repaired or repaired at all once launched. So you've got to test actual flight hardware and if it fails possibly rebuild it from scratch testing and validating the entire way.
Developing space hardware and high precision science instruments is expensive and difficult. But it's just a small portion of the overall mission cost for something like Hubble or JWST.