Praise be to Allah.
The established principle in the law of Allah, may He be exalted, is that the body of the Muslim is to be respected in life and in death. Hence the Muslims are enjoined to protect the bodies of the dead, by burying them, and not to expose them to any disrespectful treatment. The Prophet (blessings and peace of Allah be upon him) said: “Breaking the bone of one who is dead is like breaking it when he is alive.” Narrated by Abu Dawood (3207) and Ibn Maajah (1616) from the hadeeth of ‘Aa’ishah; classed as saheeh by al-Albaani in Saheeh Abi Dawood. This is the hadeeth referred to by the questioner, and this is the wording, not that mentioned in the question, as far as we know.
However nowadays there are cases of necessity which require that an exception be made from what is mentioned above with regard to the dead, so there was a need for a fatwa to give guidelines on such exceptions. As that is the case, fatwas have been issued by Fiqh Councils and trustworthy scholarly organizations stating that it is permissible to dissect the corpses of deceased Muslims if that is for the purpose of finding forensic evidence in order to determine the cause of death. This is a matter concerning which there should be no difference of opinion, because of the great interests that are served by it.
That also includes dissecting the corpse in order to find out the cause of death, even when forensic evidence is not required; rather it is for the purpose of finding out what disease the deceased was suffering from before his death, especially if it is a contagious disease.
There remains a third exception, which is dissecting the body for the purpose of training medical students and teaching them anatomical facts. Although doing that serves an important interest, it should not be done to the bodies of Muslims or to the bodies of those disbelievers who have a treaty or covenant with the Muslims. Based on that, it is permissible to do that with the bodies of those who are at war with the Muslims, and apostates.
What we have mentioned is the view held by our scholars and shaykhs, and it is also what has been mentioned in the statements of reliable fiqh councils.
Please see the answer to question no. 93820, in which we have quoted the words of the Council of Senior Scholars, the statement of the Fiqh Council, and the fatwa of Shaykh ‘Abd al-‘Azeez ibn Baaz (may Allah have mercy on him).
Shaykh al-Albaani (may Allah have mercy on him) view is that it is haraam to dissect the body of the disbeliever unless his family give permission for that, as is stated on tape no. 809 of Silsilat al-Huda wa’n-Noor. The view of the shaykh (may Allah have mercy on him) on this issue also includes the disbeliever who is in a state of war against the Muslims. And he (may Allah have mercy on him) stated that the Muslims are enjoined to bury him (the disbeliever) if he is killed on the battlefield.
Something similar was stated by Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him), as in al-Fatawaa al-Thulaathiyyah, but he said that the reason for that is that this comes under the heading of mutilation, which is haraam, and because there is the fear that they may do the same to the bodies of Muslims.
See the view of Shaykh al-Fawzaan in the answer to question no. 107345
To sum up:
We follow what is mentioned in Fataawa al-Lajnah ad-Daa’imah (fatwas of the Standing Committee), the view of the Islamic Fiqh Council, and what they mention of the conditions and guidelines on this matter.
And Allah knows best.