The Prophet Muhammad (SAWA) was putting all his efforts to teach, preach and protect Islam. He had to deal with persons who had tribal links to make their tribes near to Islam or away frm joining the enemies of Islam. He knew that many persons around him are not sincere Muslims but Munafiqs and he said it but with out naming them to avoid more harm for Islam. Allah (SW) in Quran has mentioned the hypocrites who come to the Prophet (SAWA) claiming that they believe in him, but Allah says that they are liars (Sura Al-Munafiqoon).
All the Prophets had around them good and bad persons and they could not expose the bad ones. Prophet Easa (AS) has suffered from a companion from his very close companions who reported him to the enemies to kill him but Allah (SWT) save Easa and raised him to the sky and made that betraying companion in the shape of Easa, then the enemies of Easa caught and killed and crucifies him.
Companions of Prophet Moses (AS) had among them good and bad as well, that is why, many of his companions worshipped an animal when Moses was away from the for 40 days, following one of their leaders (Al-Saamiri) and against the pious leader Haroon who was the successor appointed by Moses.