The Prophet ﷺ was bewitched, so it would appear to him that he had done something when he had not actually done it.
حدثنا يحيى حدثنا هشام قال حدثني أبي
سحر النبي ﷺ فيخيل إليه أنه قد صنع شيئا ولم يصنعه
The isnad is sahih. It is found in Bukhari, 6/276, no. 3175 (Fath), in the Book of Jizya, in the chapter "Is the dhimmi pardoned if he practices magic?" and in Muslim, 4/1719, no. 2189, in the Book of Salam, chapter on magic, and in Ibn Majah, 2/1173, no. 3545, in the Book of Medicine.We had promised earlier to point out that this hadith is found in the Sahihayn. We add to what we said on this matter that magic taking effect on the Prophet ﷺ does not contradict his prophethood, because no magic that would undermine his prophethood could ever affect him. Rather, magic could only affect him by virtue of his humanity, just as Allah Most High said about Musa, "it was made to appear to him, from their magic" [Taha 20:66]. This is exactly what happened, as Ayesha explicitly stated.Some people who claim to have knowledge have denied that magic could affect the Prophet, and so they declared daif certain hadiths found in the Sahihayn. They forgot that in the Noble Quran, "forgetting" can mean forgetting out of ignorance, not forgetting out of inattention.Then what happened?! What happened is that Allah wanted to send down protection from the seventh heaven so that all Muslims could benefit from it. So whoever protects himself with the Muawwidhatayn, or with what is mentioned in 21073, no devil and no magic will ever come near him.