The fuel/air mix has a huge dependency on the temperature of the engine. The old-school analogy is the choke on a mechanical engine. You have to run a rich mixture when the engine is cold to start it. When the engine gets hot, the mix can be leaned out. The GM engines run as lean as possible to reduce the emissions that you're failing. When the thermostat is stuck open, the coolant flow is too high for the engine to get to its proper operating temperature. Replacing the thermostat reduces the water flow and allows the engine to get to full operating temperature and the computer will lean out the fuel/air mixture properly.