The ECM is the cars computer. This computer has a program, like any program you use on your desktop computer. It takes inputs from sensors, looks at their values, compares those values to values it has stores (lookup tables), and based on the values, makes yes/no decisions. These yes/no decisions are turned into actions (add fuel, remove fuel, change ignition timing, activate the fan etc.etc. A Scan tool is a device that can "talk" to the computer. It says basically "Are there any problems?" And the computer tells it in the form of trouble codes, or malfunction codes. Or you can view certain data that the computer is basing its adjustments on. When people talk about code, theyre talking about the program that is running on the computer, or a malfunction indicator (Malfunction code). ie: My car spit out a code 21. This means the ECM took the throttle position value from the sensor, looked at its value table and says the throttle position sensor value is lower than it should be. Then you use your scan tool and view the data the ECM is seeing (a data stream) to see if the value is in fact wrong.
These lookup tables are store on a computer chip inside the computer. Lots of people modify these computer chips. Some modify the lookup tables, while the programmers of the bunch change the actual computer program.
The proble, with the GN computer is fueling for example has only like 9 table entries, making for a very 2 dimensional fuel curve. GM did their best by interpolating the fuel values from one table cell to another, but some cars fuel requirements are very different than the table will allow. In the case of a cam for example, you may need a LOT more fuel when the cam "comes on", but it may come on between table entries. Unfortunately you cant do anything about it but add extra in the next table cell and hope you do OK.
Enter the aftermarket ECM. They generally have tables with a lot more data areas. More area means more resolution. Instead of 8 cell entries, they may have 100. Meaning you can more accurately fuel an engine based on operating parameters and have less of a chance of needing something extra, where you cant put it. Aftermarket ECU's are generally faster speed wise too. Where the GN computer is relatively slow (I forget exactly but something liike 160mhz sticks in my head) where as the aftermarket ECU's make more calculations per second, ensuring you less calculations are wrong.
Thats basically it in a nutshell. I'm sure someone will chime in and correct/add to this.