Connected bodies and the choice of system
Bodies joined by a string share one acceleration, which comes from the whole system's external forces, and the tension inside it is then found from the free-body diagram of one body.
From AP Physics C: Mechanics.