There are quite a few books on this topic. Here is a storehouse of many of them; the Studies in Early Buddhist Meditation & Early Buddhist Epistemology sections are particularly relevant. Additionally, Sujato has written A History of Mindfulness & Sects & Sectarianism; he & Brahmali also wrote The Authenticity of the Early Buddhist Texts, which is probably the best book to read first.

The Buddha died ca. 404 BCE, while the Nikayas & Agamas we have both come from a common stock of teachings. These proto-Nikaya-Agamas were scattered throughout northern India when the Buddha died, and they came to be collected & collated together at the Second & Third Councils, probably held ca. 280 BCE & 250 BCE (this is also when they were translated into Pali). A lot happened over those ~150 years, but the specifics are obscure. Usually, talking about this period of time with a Buddhist will reveal what many of their assumptions are about the correct ways to approach these texts.