Advanced submarine-hunting warships being built for the Royal Navy and Norway will be produced at the same time.