OBDI and OBDII are VERY Different and cannot be swapped. You cannot swap out OBD in general (have it work and be emissions legal, that is). It is designed for a particular engine/model year. For example, It's possible that a 95 and 96 325 might be interchangable, but I can almost guarantee that you cannot swap a 318 for a 325. It might physically hook up if all the sensors are the same, but OBD is a program. It expects certain sensors to return specific values, etc. which would be different due to engine size, etc. Usually, if someone does an ENGINE swap they will swap the OBD/ECM, wiring harness, etc. to kept it working as a unit.
A 318 <-> M3 swap is very unlikely to work. Isn't the 318 a 4 cylinder? No way would that work.
The primary, official purpose of OBD (On Board Diagnostic) is to monitor emissions controls and provide a technician with the information to repair a faulty emission control device. This was mandated by the Federal Government in the early 80s. It then evolved, also by government mandate, into OBDII.
As technology has evolved, manufacturers added additional features and functions to the OBD computer. In many cases, the ECM (Engine Control Module) was added into the same electronics package as OBD. Some manufacturers made the ECM a separate unit, but it communicates with the OBD. Again, the OBD is mainly the diagnostic interface. You could have other computer modules in the car for engine control, air bags, security, etc. The OBD may talk to all of these, and they may be in one package, or three. It is REQUIRED to provide emissions diagnostics in standard formats - everything else is up to the manufacturer.
Used OBD/ECMs are sold usually because they are:
1. Left over after an engine swap.
2. Left over after an upgrade (usually you send your old one back as a core).
3. Hardcore performance tuners eliminate the OBD/ECM, usually for racing.
3. Part of a wrecked car being parted out.