Not a whole factory but whole other tooling, so yes? The chassis is different, the screen is different, the mainboard is different, the layout is different, the battery is different, I think the camera was also different. Only thing shared between the other models was the buttons and the lightning port.
It's a huge cost for something that sold (relatively) poorly.
The should have designed two phones, normal size and small, where the internals are the same and the only difference is the case/battery/screen.
Apple has huge margins, it's not a problem unless you think about margins. Making more money is normally good, even if the margin is slightly lower.