Casualties, enemy fire, and exhaustion negatively affect discipline, and should discipline fall below a certain threshold (15% by default, this threshold can be further improved by skills) the company will break and retreat. Discipline is an abstraction of morale and affects accuracy. You can access the company set-up in the pre-battle deployment menu.
Artillery and cavalry also utilize this system, with differentiated company types existing for both. Between Empires completely replaces Warband's native division system, instead using a new company system that allows players to split infantry units into multiple line, guard, or light infantry companies.