All praise is due to Allah, and may peace and blessings be upon the Messenger of Allah.
It is authentically reported that the Prophet ﷺ said:
“When you hear a donkey braying, seek refuge in Allah from Satan, for it has seen a devil.” Narrated by Al-Bukhari and Muslim.
It is also authentically established that the devils are chained during the month of Ramadan. However, chaining them does not necessarily mean that they are completely prevented from moving. Rather, their ability to cause harm and mislead people is weakened.
Shaykh al-Islam Ibn Taymiyyah, may Allah have mercy on him, stated that chained devils may still cause harm, but their harm is less and weaker than it is outside Ramadan.
Accordingly, there is no contradiction between the two hadiths. The donkey's braying is connected to its seeing a devil, whether that devil is chained or not. The chaining of devils does not necessarily mean that they disappear or that all their effects cease.
Conclusion: Chaining the devils during Ramadan weakens their evil, but it does not necessarily mean that they disappear or are prevented from all movement. Therefore, there is no contradiction between a donkey braying during Ramadan and the hadith about the chaining of devils.
These matters belong to the unseen, and we believe in them as they have been reported in the religious texts, without trying to speculate about the details of how they occur.
And Allah knows best.