Does battery affect how engine runs

A poor battery or dirty battery cables can absolutely cause a car to run poorly, sometimes in very odd ways. Some cars are much more sensitive than others.

Auto computers collect most of their information based on resistance readings. They read resistance by sending a low voltage signal to the sensor, and counting how long it takes for the signal to charge a capacitor in the computer up to some threshold voltage. If the supply voltage is doing odd things as the computer is scanning its inputs, the inputs appear to be changing in irratic ways, and how the computer will respond is anyones guess.

Since transmissions started to be computer controlled, more than one transmission problem has been solved by battery replacement.