Straying from the straight path is something that certainly that took place amongst a group of the Sahabah (companions of the prophet (pbuh)) after the prophet’s (pbuh) demise because:
Firstly, this is something that the most authentic Islamic sources verify and doesn’t exclusively belong to Shia sources. There are mutawatir hadiths from the prophet (pbuh) that can be found in the six Sihahs and other authentic sources of our Sunni brothers with various authentic chains of narrators that state that a majority of the prophet’s (pbuh) companions turned away from his ways and traditions and returned to their past after his demise and that it is this very backwards movement that has caused them to be deprived of the drinking from the pool of Kawthar on the Day of Judgment and to be turned away from it and led to the Hellfire.
Secondly, the apostasy and denouncement of faith that these hadiths speak of, doesn’t refer to the famous disbelief and kufr of kafirs (it doesn’t mean that they became kafirs), what is meant is that instead of staying with the values and traditions of the prophet (pbuh), they returned to their old values they had during the Jahiliyyah and their old mindset while remaining Muslim in name at the same time. Also, it doesn’t mean that they were Sunnis during the prophet’s (pbuh) time and turned Shia after his passing or vice versa, although it is true that the name “Shia” was coined by the prophet (pbuh) and that he used this term to refer to the followers of Ali (as).
In order to reach an answer to your inquiry, it is better if we first have a look at the famous hadiths of Kawthar.
Believing in the pool of Kawthar is a common belief amongst different Islamic sects. There are mutawatir hadiths (hadiths that speak of a certain concept and are so high in number from various narrators of hadiths that one becomes sure that the hadith has actually been issued from the prophet (pbuh) or imams and that there is no chance that all of them have mistakenly or purposely narrated the hadith incorrectly) from the prophet (pbuh) which have been narrated in the most authentic sources of both the Shia and Sunni schools of thought. The hadiths says that on the Day of Judgment, all of the companions of the prophet (pbuh) will rush to the pool of Kawthar in order to quench themselves with its water next to the prophet (pbuh), but only a few of them will be allowed to do so and most of them will be turned down and sent away to the Hellfire by the angels of chastisement. When this happens, they will cry out to the prophet (pbuh) for help, and the prophet of mercy (pbuh) will ask what the reason for such is in order to help them; it will be told to him on behalf of Allah (swt) that: “They innovated in religion after your passing, and this resulted in their apostasy.” This message from Allah (swt) will cause the prophet (pbuh) to curse them as well and send them away from himself.
These are a few examples of this hadith:
1- Sahl ibn Sa’d reports the prophet (pbuh) saying: “I will go to the pool of Kawthar before you…then a group of those whom I know and know me will come to me, then we will distance from each other (and they won't be allowed to enter) I will say: “They are with me.” It will be said: “You aren't aware, they innovated after you.” I will then say: “May he stay away, may he stay away, the person who changed things after me.”
2- Abu-Hurayrah reports the prophet (pbuh) saying: “On the Day of Judgment a group of my companions will come to me, but will be sent away from the pool of Kawthar. I will say: “O Lord! [These are] my companions!” It will be said: “You don’t know, they caused innovation in your religion after you; they have strayed from the path of truth and guidance and have returned to their old beliefs.”
3- Abu-Hurayrah reports the prophet (pbuh) saying: “I will be standing next to the pool of Kawthar when a group that I know will arrive. (One who has been appointed by Allah (swt) to watch them) will come out and tell them: “Come, (it is time to go).” I will say: “Where?” He will answer: “By Allah, towards the Hellfire.” I will respond: “What have they done wrong?” He will say: “They returned to their old beliefs after you left.” Then another group will be brought that I also know. (Once again an appointee by Allah (swt) to watch out for them will come) and say: “It is time to go.” I will say: “Where?” He will say: “Towards the Hellfire.” I will ask: “What have they done wrong?” He will respond: “They turned to their old beliefs after you left. I don’t think any of them will be delivered except a number like that of camels when they separate from their herd and get lost and die out because of not having a shepherd (indicating that their number is extremely low).”
4- Umm Salmah reports the prophet of Islam (pbuh) saying: “I will go to the pool of Kawthar before you. So be aware of me! None of you will come (to enter the pool) unless he/she will be sent away from it, the same way a stranger camel is sent away from the watering trough. I will ask: “What is the reason for such?” It will be said: “You don’t know what innovations they caused after you. Then I will say: “May they stay away!”
5- Abu Saeed Khadari reports the prophet (pbuh) saying: “O people! I will go to the pool of Kawthar before you. A group of my companions will be shown to me and will then be led to the Hellfire. One of them will cry out that O Muhammad! I am “so and so” the son of “so and so” and I will reply that I know who they are but will also know that they innovated in religion and returned to their old beliefs after me.”
6- Umar ibn Khattab reports the prophet (pbuh) saying: “I [the prophet (pbuh)] will try to prevent you from going to the Hellfire, but you will all overpower me and rush towards it the same way butterflies and grasshoppers swarm towards something, I will almost free you [from the Hellfire], I will go to the pool of Kawthar before you, and all of you will follow scattered. I will recognize you by name and face, the same way the owners of camels can distinguish between stranger camels and their own. Afterwards, you will be taken to the Hellfire and I will swear by God, saying: “O Lord! My group?! My nation?!” It will be said: “You don’t know what innovations they caused after you in religion; they all moved backwards and regressed to their old beliefs.”
In some Shia Imamiyyah sources, similar hadiths have been mentioned. For instance, in Biharul-Anwar it has been narrated that Abu Basir reported Imam Sadiq (as) saying: “I asked the imam (as) if all but three individuals, Abu Dharr, Salman and Miqdad turned away from their faiths [after the prophet (pbuh)]. He replied: “What about Abu Sasan and Abu Umrah Al-Ansari?!”
As you can see, the imam (as) rejects Abu Basir’s assumption that only three individuals maintained their faith after the prophet (pbuh) by naming two more.
Concerning this hadith by Abu Basir, a few points need to be kept in mind:
a) This hadith hasn’t been mentioned in any important authentic hadith sources.
b) The word “ناس” which has been used in the hadith, refers to the companions of the prophet (pbuh) and the Muslims of that time, not all the Muslims till today. The reason being that all of those who have been considered on the straight path are of the companions of the prophet (pbuh), while we are sure there have been others who have been on the straight path but weren’t of the Sahabah, therefore, that necessitates that those who turned away from their faiths that this hadith is speaking of were also of the prophet’s (pbuh) companions.
c) What the abovementioned hadith and other hadiths that state a number higher than this number for those who maintained their faiths are apparently trying to say is that a small number only remained, and aren't after really determining an exact and specific number. Also, as was said before, what is meant by denouncing faith is that they returned to their old beliefs, not that they returned to their old religions and became idol-worshippers.
Conclusion: To sum all of the aforesaid hadiths up, one can say that:
a) The word “Ihdath” which has been mentioned in the hadiths above means “innovation”, and what innovation denotes is to add to religion new beliefs that haven’t stemmed from the Quran and traditions. Bid’ah or innovation is one of the sins that according to direct and explicit authentic hadiths by the prophet (pbuh), destroys the previous good deeds of the innovator and makes them stray from the path of Islamic values.
b) According to what the hadiths above are surely saying, a group of the companions of the prophet (pbuh) innovated in religion after him (انک لا تدری ما احدثوا بعدک). The sin this group has committed is so great that it has caused them to distance from Allah (swt) and his messenger (pbuh) and to be denied the pool of Kawthar.
c) It can't be claimed that these hadiths are speaking of those who had turned Muslim a little before and after the prophet’s (pbuh) demise in places far from the Muslim capital and then denounced their faiths shortly afterwards which are referred to as the “ردة” (Raddah), because according to the best defenition for “sahabi”, the Raddah weren’t considered sahabis (companions of the prophet (pbuh)).
“The most correct definition for sahabi that we could find is:
“One who meets the prophet (pbuh) while believing in him being the prophet and dies a Muslim.” The Raddah lack some of this criteria because they died as disbelievers. Therefore, this definition doesn’t cover them, while the prophet’s (pbuh) sayings mentioned above were all speaking of the Sahabah (Sahabis).
The common usage that normal people use for sahabi also doesn’t cover the Raddah, because Sunni scholars have said:
“According to the common usage of this term, only those who have been with the prophet (pbuh) for a long time are considered sahabis.” Saeed ibn Musayyib believes this “long time” to be one to two years. None of the Raddah ever lived with the prophet (pbuh) for this long. Ibn Athir has directly said that the Raddah weren’t considered part of the Sahabah.
Phrases like these have been used in the hadiths that speak of the pool of Kawthar: “...رجال منکم...” (Men from you [the prophet]), “...اعرفهم و یعرفوننی...” (I know them and they know me) and “...رجال من اصحابی...” (Men from my companions).
These phrases show that the Raddah surely weren’t the ones being addressed, because none of them were neither of the great companions of the prophet (pbuh), nor were known by him by the face or name and descent, especially since some of the great Sahabah have admitted to their innovations after the prophet’s (pbuh) demise. These admittances clearly show that the innovations the hadiths mention, don’t belong to people who had recently become Muslim like the Raddah, but to those who had been Muslim for a while.
d) Another point that confirms what was said above is what has been narrated by Zayd ibn Arqam, the companion of the prophet (pbuh). He is one of those who have narrated this hadith (the pool of Kawthar) from the prophet (pbuh). When he narrated this hadith for the people, they asked him: “How many were you when the prophet (pbuh) said this hadith?” Zayd answered: “Around 800 to 900 people.”
e) In addition to all of the above, if we assume that it is true that those who had just become Muslim a little before or after the prophet’s (pbuh) demise (the Raddah) were the ones who became apostates and kafirs afterwards (because they weren’t ready to pay taxes to the newly established government of Abu Bakr and were accused of turning away from religion as a result); in this case too, these hadiths still can't be referring to them because the hadiths listed in the beginning of the article were speaking of “innovation”, while none of the Raddah ever committed any innovation; what they did was that they turned away from Islam and returned to being kafirs, and there is a great difference between apostasy and innovation. Innovation means to bring something into religion that doesn’t belong to it and this isn't something that any of the Raddah ever did; what they did was that they denounced their faiths, and this is called Irtidad or apostasy.
In irtidad, one completely returns to his/her own old beliefs and denounces his/her faith, while this isn't the case in bid’ah or innovation; in innovation, one maintains his/her own beliefs, but adds things to religion that don’t belong to it. The Irtidad these hadiths speak of stem from innovation, and doesn’t mean that they actually put Islam aside completely. In other words, they first innovated, and this resulted in their practical denouncement of their faiths; and what is meant by this denouncement isn't that they totally put Islam aside, but it means that they returned to the values they had before Islam while remaining Muslim in name.
f) In these hadiths, “تغییر” and “تبدیل” (changing and alteration) have been mentioned: “سحقاً سحقاً لمن غیر بعدی”/ “سحقاً سحقاً لمن بدل بعدی”. This wording clearly shows that some of the Sahabah changed and altered some important truths of Islam after the prophet (pbuh) passed away, and this bad act has aroused Allah (swt) and the prophet’s (pbuh) anger and wrath and the prophet (pbuh) curses them (سحقاً) for it.
A number of Sunni scholars believe the terms “سحقاً”, “غیر” and “بدل” to mean altering religion and turning away from it. Qastalani, a commentator of Sahih Bukhari, says: “These terms indicate that those whom these hadiths refer to had altered their religions (bid’ah), because if they had committed any sin other than altering religious values, the prophet (pbuh) wouldn’t have used the word “سحقاً” [and cursed them], but would strive to free them of their problems instead and would intercede for them [which shows what they did was very big].
These phrases also indicate their denouncement of their faiths, because the era before the Sahabah and Islam, is the era of Jahiliyyah (ignorance), and returning to such an era is turning away from Islamic values towards the values of those times.
In his explanation of the hadith, Ibn Hajar Asqalani says: “قوله: ما برحوا یرجعون علی اعقابهم” ای یرتدون (When the prophet (pbuh) says: they move backwards, it means they are turning away from their religions).
h) As was mentioned earlier, in one of the hadiths the prophet (pbuh) says: “I don’t think any of them will be delivered, except for a small number like the number of camels that separate from their herd.”
This hadith explicitly says that only a few individuals will be saved and will reach salvation. As you saw, the issue of the apostasy of a majority of the Sahabah isn't something only mentioned in Shia sources, but has also been thoroughly reflected in Sunni sources as well.
Also, the apostasy of the Sahabah doesn’t mean that they were Shias, and after the prophet (pbuh) they became Sunnis, or that they were Sunnis and after the prophet (pbuh), became Shias; what it means is that they turned away from Islamic values after the prophet (pbuh) and Islam and returned to the values of the Jahiliyyah while maintaining their being Muslim at the same time. Nevertheless, this fact is true that the first name to be coined during the prophet’s (pbuh) time was the name “Shia”, and the first person to use it for the followers of Ali (as) and call them “the Shia of Ali (as)” was the prophet (pbuh) himself.
Abu Hatam Razi writes: “The first name to be coined during the prophet’s (pbuh) time was the name “Shia”. This name was the title of four of the Sahabah: AbuDhar, Salman, Ammar and Miqdad.”
 Sharh Sahih Muslim, vol. 15, pg. 5 and vol. 16, pg. 59; Umdatul-Qari, vol. 23, pg. 135/ Kirmani, Sharh Sahih Bukhari, vol. 23, pg. 63; Ibn Abdil-Birr, Al-Tamhid, vol. 2, pg. 291.
 “انی فرطکم علی الحوض،... لیردن علی أقوام أعرفهم و یعرفوننی، ثم یحال بینی و بینهم. فأقول: انهم منی، فیقال: انک لاتدری ما أحدتوا بعدک، فأقول: سحقاً سحقاً لمن غیّر بعدی” Sahih Bukhari (kitab riqaq), chapter 53, hadith 6212; Sahih Muslim (kitab fada’il), chapter 9; Baghawi, Masabihul-Sunnah, vol. 3, pg. 537.
 The explanation of the hadiths of Sahih Bukhari by Mustafa Dib al-Bugha, under Sahih Bukhari, vol. 5, pg. 2407.
 “یرد علی یوم القیامة رهط من أصحابی، فیجلون عن الحوض، فأقول: یا رب اصحابی؟ فیقول: انک لاعلم لک بما أحدثوا بعدک، انهم ارتدوا علی ادبارهم القهقری” Sahih Bukhari (kitab riqaq), chapter 53, hadith 6213.
 “بینا أنا قائم إذا زمرة، حتی إذا عرفتهم خرج رجل من بینی و بینهم، فقال: هلم، فقلت: أین؟ قال: الی النار والله، قلت: و ماشأنهم؟ قال: إنهم ارتدوا بعدک علی أدبارهم القهقری. ثم إذا زمرة، حتی إذا عرفتهم خرج رجل من بینی و بینهم، فقال: هلم، قلت: أین؟ قال: إلی النار والله. قلت: ماشأنهم؟ قال: أنهم ارتدوا بعدک علی أدبارهم القهقری، فلا أراه یخلص منهم الا مثل همل النعم” Sahih Bukhari (kitab riqaq), chapter 53, hadith 2115; Ibn Manthur, Lisanul-Arab, vol. 15, pg. 135; Munthiri, Al-Targhib wa Al-Tarhib, vol. 4, pg. 422; Ibn Athir, Al-Nihayah fi Gharibil-Hadith, vol. 5, pg. 274; Ibn Hajar, Fat’hul-Bari, vol. 11, pg. 475; Ayni, Umdatul-Qari, vol. 23, g. 142; Qastalani, Irshadul-Sari, vol. 9, pg. 342.
 “انی لکم فرط علی الحوض، فایای! لایأتین أحدکم فیذب عنی کما یذب البعیر الضال، فاقول: فیهم هذا؟ فیقال: انک لاتدری ما أحدثوا بعدک، فأقول: سحقاً” Sahih Muslim (kitab fada’il), chapter 9, hadith 2295.
 “... ایها الناس أنا فرطکم علی الحوض یوم القیامة ولیرفعن الی قوم ممن صحبنی و لیمرن بهم ذات السیار فینادی الرجل یامحمد أنا فلان بن فلان و یقول آخر یا محمد أنا فلان بن فلان، فأقول: اما النسب فقد عرفته و لکنکم أحدثتم بعدی و ارتددتم علی اعقابکم القهقری” Musnad Ahmad ibn Hanbal, vol. 4, pg. 79; Ibn Abdil-Birr, Al-Tamhid, vol. 2, pg. 299.
 “انی فنمسک بحجزکم هلم عن النار و تغلبوننی تقاحمون فیه تقاحم الفراش و الجنادب، و اوشک أن أرسل حجزکم و أفرط لکم علی الحوض و تردون علی معا و أشتاتاً، فأعرفکم بأسمائکم و سیماکم، کما یعرف الرجل، الغریبة فی ابلة، فیؤخذ بکم ذات الشمال، و أناشد فیکم رب العالمین، أی رب رهطی، أی رب امتی، فیقال انک لاتدری ما أحدثوا بعدک، انهم کانوا یمشون القهقری” Ibn Abdil-Birr, Al-Tamhid, vol. 2, pg. 301.
 “قلت لأبی عبدالله (ع): ارتد الناس الاّ ثلاثة: ابوذر و سلمان و المقداد؟ قال ابوعبدالله: فأین أبو ساسان و ابوعمرة الأنصاری” Biharul-Anwar, vol. 23, pg. 352.
 Ibn Athir, Al-Nihayah fi Gharibil-Hadith, vol. 1, pg. 351.
 Sunan Ibn Majah, Introduction of chapter 7, hadith 49.
 Sahih Bukhari (kitab riqaq), chapter 53; Sahih Muslim (kitab fada’il), chapter 9.
 Ibn Hijr, Al-Isabah fi Tamyizil-Sahabah, vol. 1, pg. 4.
 Raghib, Mu’jam Alfadhil-Quran, pg. 382; Ibn Athir, Asadul-Ghabah, vol. 1, pg. 26.
Asadul-Ghabah fi Ma’rifatil-Sahabah, vol. 1, pg. 25; Fat’hul-Bari, vol. 7, pg. 4.
 Al-Nihayah fi Gharibil-Hadith, vol. 2, pg. 214
 Sahih Bukhari (kitab riqaq), chapter 53; Sahih Muslim (kitab fada’il), chapter 9.
 “... فاعرفکم باسمائکم و سیماکم...” Ibn Abdil-Birr, Al-Tamhid, vol. 2, pg. 301.
 See: Ibn Qutaybah, Al-Ma’arif, pg. 134; Sahih Bukhari (kitab maghazi), chapter 33.
 Hakem Neyshabouri, Mustadrak, vol.1, pp. 76-77; Dhahabi, Talkhisul-Mustadrak, vol. 1, pp. 76-77; Baghawi, Masabihul-Sunnah, vol. 3, pg. 551; Tabarani, Mu’jam Kabir, vol. 5, pp. 175-176.
 Ragheb Isfihani, Mu’jam Mufradat Alfadhil-Quran, pg. 198.
 Sahih Bukhari (kitab riqaq), chapter 53 and (kitab fitan), chapter 1; Sahih Muslim (kitab fada’il), chapter 9.
 Irshadul-Sari, vol. 9, pg. 340; Nawawi, Sharh Sahih Muslim, vol. 15, pg. 60.
 Sahih Bukhari (kitab riqaq), chapter 53.
 “... هل شعرت ماعملوا بعدک؟ والله مابرحوا یرجعون علی أعقابهم” Sahih Bukhari (kitab riqaq), chapter 53; Fitan, chapter 1; Sahih Muslim (kitab fada’il), chapter 9.
 Fat’hul-Bari, vol. 11, pg. 476; Al-Nihayah fi Gharibil-Hadith, vol. 4, pg. 129.
 “... فلا اراه یخلص منهم الا مثل همل النعم” Sahih Bukhari (kitab riqaq), chapter 53, hadith 2115.
 Irshadul-Sari, vol. 9, pg. 342; Umdatul-Qari, vol. 23, pg. 142.
 Suyuti, Al-Durrul-Manthur, vol. 8, pg. 589; Sibt Ibn Jawzi, Tadhkiratul-Khawass, pg. 56; Abu Na’im, Hilyatul-Owliya’, vol. 4, pg. 329; Tarikh Baghdad, vol.12, pg. 289.
 Muhammad KurdAli, Khutatul-Sham, vol. 6, pg. 245.