Like others have said, expansion ports are surprisingly expensive. When you look at the two examples you provided (Apple II and IBM), they weren't exactly the cheapest options for computers back in the day.
Even today, those 50 pin edge connectors can be $3+ each even in large quantities. I imagine (but cannot confirm) that Steve Jobs worked his magic back in the 70's and 80's and managed to get them for a bargain. But I'm only speculating.
However, the edge connector is hardly the entire cost of expansion ports. You have "glue" logic for device selection (such as 74LS138 multiplexers), buffers, shielding, etc. Plus, it is NOT a trivial task to design expansion buses in a machine. Especially for anything over a couple MHz.
The Apple II (and IBM, really) wouldn't have been a very exciting machines if it weren't for the expansion buses. But all of these ports came at a price. Which is why the more "budget friendly" computers such as the VIC-20, Commodore 64, Tandy CoCo, etc. used external edge connectors that had fewer pins. And, they typically only had one or two of them if any at all.
So it's impossible to say that expansion slots "cost 20% more" or "40% more". There are too many variables involved.
With the exception of the Apple II line, you only really ever saw them in droves on computers marketed for business (IBM, Amiga 2000/3000/4000, etc.). In fact, I would argue that the only reason you saw them on PC compatibles (like Compaq) is because they were trying to mimic the IBM completely. If IBM had created the 5150 with no expansion slots and used all serial/parallel connectors, the clone business may have been a completely different animal.
So, I think it's safe to say that expansion ports are expensive.