You are not aware that the exact same thing is done for petrol and diesel cars (i believe a bmw 318d is the exact same engine as a 323d, a part from software/firmware). Cpus, gpus etc. etc.
There are two basic versions of that engine both have four cylinders, a 1.8L and a 2.0L, that's only a difference in sleeves and pistons but it is not just a software change.
There is no 2.3L version of that engine and I'm not aware of a 323d.
Exactly. Many years ago my father drove a Rover 75 in the UK which used an older version of BMW's 318d engine, but of course hobbled in software so as not to deliver as much power/torque as the same engine in a BMW.
For a couple hundred quid you could "chip" the engine to match or exceed the rated power of the BMW version. They even installed it in such a way that the chip could be removed before you took it in for a service so as to avoid warranty concerns etc.