Firmware is low level code that allows the computer - a Z4 car in this case - to start up from an off condition (boot-up) and controls the electronic interaction between CPU, memory, storage and peripheral interfaces. This is often called the BIOS in PC terms but all computing systems which (which nowadays is everything pretty much) have firmware. The firmware also gets the operating system to load and run.
The operating system is the software that sits on top of the firmware such as Windows, OSX, iOS, Android etc. BMW have their own operating system that interfaces to the rest of the car over the CANbus and many compnents fo the car, engine, gearbox etc have their own firmware. Operating systems control how an application of a peripheral accesses other parts of the computer. It controls how users or other computers can access this computer via APIs (application programmable interfaces).
Applications are what run on top of the operating system such as Word, Safari, Chrome, Internet explorer etc.
There are variations on this theme but that is the general schema of how this works.
In the context of a car, all this often comes embedded in one lump of software and they all it - technically incorrectly - the "firmware". An error in upgrading such firmware can be catastrophic and so there are often two "banks" of firmware so there is a backup in case the main one corrupts during an upgrade etc.