Please put the hadith in context
First of all slavery was there before Islam and people had their own "rules" about it, according to those rules slaves where neither regarded as equal humans nor would anybody care about their feelings or lives as they were simply regarded as a property, which should work as expected by the owner, else it would be punished etc..
Similar to slaves the women had a bad status prior to Islam, it was common to bury daughters alive, having a lots of women and a lot of kinds of so called "marriages" were practiced which Islam declared as haram and void (just to mention some examples).
In this light the ahadith you mentioned should be regarded, not from the perspective of the 21st or 15th (hijri) century. Today we may say that no slavery exists and one of the goals of Islam as some scholars like 'Allal al-Fasi said is achieved: slavery was declared as illegal by all known governments and countries.
Further the ahadith must be regarded from the perspective of Arabic language (for example the tendency to exaggerate or emphasize) vs. the literal meaning, its circumstances etc. and interpretation.
Punishments in Islam include slaves
Allah the Almighty says:
O you who have believed, prescribed for you is legal retribution for those murdered - the free for the free, the slave for the slave, and the female for the female. But whoever overlooks from his brother anything, then there should be a suitable follow-up and payment to him with good conduct. This is an alleviation from your Lord and a mercy. But whoever transgresses after that will have a painful punishment. (2:178)
This verse is one example of verses that include slaves in punishments. However Islam offers different options:
- ransom (this option according to al-Qurtobi was something new and which was not practiced before Islam)
The verse also makes clear which of the options is regarded as the best, as per Islam.
One could further say that it is agreed upon that proved offenses can or even must be punished. As long as the punishment is suitable and not "harder" than allowed there's no disagreement among scholars on this matter. However punishing without a reason or offense is another topic.
Ahadith which contradict your quotes to some extent
The ahadith above also seem to contradict to others saying:
I came to Ibn 'Umar as he had granted freedom to a stave. He (the narrator further) said: He took hold of a wood or something like it from the earth and said: It (freedom of a slave) has not the reward evert equal to it, but the fact that I heard Allah's Messenger (way peace be upon him) say: He who slaps his slave or beats him, the expiation for it is that he should set him free.
(Sahih Muslim, see also the next hadith in Sahih Muslim)
This is the community and society our prophet () taught and re-educated.
Nevertheless one must honestly say: The majority view among scholars is that freeing a slave is not obligatory in the given case. Based on reports such as another sahih hadith saying:
I slapped a slave belonging to us and then fled away. I came back just before noon and offered prayer behind my father. He called him (the slave) and me and said: Do as he has done to you. He granted pardon. He (my father) then said: We belonged to the family of Muqarrin during the lifetime of Allah's Messenger (may peace be upon him. and had only one slave-girl and one of us slapped her. This news reached Allah's Apostle (ﷺ) and he said: Set her free. They (the members of the family) said: There is no other servant except she. Thereupon he said: Then employ her and when you can afford to dispense with her services, then set her free.
While imam Malik (and his student) and al-Laith ibn Sa'ad held the opinion that in case of a hard hitting or beating or any kind of torture of a slave the ruler must order freeing the slave from it's owner.
Punishing a slave for a misdeed etc. therefore is not haram in Islam the kind of punishment may differ and one can hardly regard it as permissible to torture in Islam (and even those who oppose Malik and al-Laith say that it (Imam an-Nawawi -see here- in this context quoted al-Qadi 'Iyad who named something like burning and cutting extremities etc.).
There are even more severe ahadith like:
"Whoever castrates his slave, we will castrate him, and whoever mutilates his slave, we will mutilate him." This is the wording of Ibn Bashshar (one of the narrators).
(Sunan an-Nasa-i and in a different wording in Sunan abi Dawod)
"Whoever kills his slave, we will kill him, and whoever mutilates his slave, we will mutilate him."
(Sunan an-Nasa-i -there are more versions of this hadith-, Sunan abi Dawod and Jami' at-Tirmidhi)
However the scholars don't take these ahadith in a literal meaning. The interpretation are as follows (as quoted by Aabady محمد شمس الحق العظيم آبادي in his 'Awn al-Ma'abud عون المعبود -see here- I will distinguish the statements of at-Tirmidhi from this of Aabady by marking the first by (t) and the later by (a), if there's a difference in both statements):
- Killing a free for killing a slave is allowed: Ibraheem an-Nakha'i, Sufyan a-Thawry (a).
- Killing a free for killing a slave that one doesn't own is allowed: abu Hanifah and Sufyan a-Thawry (t).
- Killing a free for killing a slave is not permissible: Hassan al-Basri, 'Ata' ibn abi Rabaah, Malik, a-Shafi'i and Ahmad.
The above statements don't make a difference between a slave who converted to Islam and other slaves as it seems.
There are further ahadith showing that Islam asks as to treat slaves good, as a part of the family, like here in Sahih al-Bukhari, here and here in Sahih Muslim. And the sunnah of the prophet (9 himself is described in a Sahih hadith saying:
'A'isha reported that Allah's Messenger (ﷺ) never beat anyone with his hand, neither a woman nor a servant, but only, in the case when he had been fighting in the cause of Allah and he never took revenge for anything unless the things made inviolable by Allah were made violable; he then took revenge for Allah, the Exalted and Glorious.
Back to the two reports in question
Both ahadith have one major goal to show that women (more explicitly wives) shall be threaten even better than slaves. And they are rather regarded as an interpretation of the verse saying (the Chapter title "The virtue of spending on one's family and slaves, and the sin of the one who neglects them or withholds maintenance from them" in Sahih al-Bukhari already pointed at this fact):
... But those [wives] from whom you fear arrogance - [first] advise them; [then if they persist], forsake them in bed; and [finally], strike them. ... (4:34)
Ibn Hajar (see for example here -in Arabic-) and other commentators of Sahih al-Bukhari also quoted different versions of the report of al-Bukahri and the wording used for example, "flog", was also replaced by "beat" or "hit" or "strike". And in one version the sentence was not in a negative form rather in the following wording (my own interpretation from what I read in those sources):
Some of you flog his wife as he flogs a slave
Such a version is rather describing what some people do, and this would resolve the whole issue, because it shows a fact and doesn't encourage it.
And al-Bukhari actually mentioned such a hadith elsewhere saying:
That he heard the Prophet (ﷺ) delivering a sermon, and he mentioned the shecamel and the one who hamstrung it. Allah's Messenger (ﷺ) recited:-- 'When, the most wicked man among them went forth (to hamstrung the she-camel).' (91.12.) Then he said, "A tough man whose equal was rare and who enjoyed the protection of his people, like Abi Zama went forth to (hamstrung) it." The Prophet (ﷺ) then mentioned about the women (in his sermon). "It is not wise for anyone of you to lash his wife like a slave, for he might sleep with her the same evening." Then he advised them not to laugh when somebody breaks wind and said, "Why should anybody laugh at what he himself does?"
And also in other sources like Sunan ibn Majah:
'The Prophet delivered a sermon then he made mention of women, and exhorted (the men) concerning them. Then he said: 'How long will one of you whip his wife like a slave, then lie with her at the end of the day?'
While on the other hand there are ahadith showing that hitting or beating the wives was for example rather common under the tribe of Quraish, while the Aws and Khazraj didn't beat their wives at all. So Islam allowed beating, but not a harmful one.
In both these ahadith the focus is on the wives, not the slaves. And none of the commentators -as far as I could find- discussed the slaves in this context. Note that the hadith from Sunan abi Dawod also shows the first step in the order from the verse too, by "advising/ordering" Laqit to advise his wife -who has a "bad tongue"-.
Sheikh ibn 'Uthaymen (as quoted in this article), actually explained the comparison between women and slaves in the hadith version as follows: As if one is beating somebody with whom he has any kind of relationship, a person who has no value or place in his heart. While a husband has a special relationship with his wife which must be respected and taken into account.
One must be aware that people who beat their wives would beat their slaves in a harder and with a hardness and more heartless manner. This is how one could imagine the life of slaves before Islam and before people saw and witnessed and learnt from our Messenger (). Islam didn't prohibit many things at once, but step by step!
From all described above I think it makes sense to re-interpret and understand the ahadith as folows:
"None of you should flog (beat or hit) his wife (for a given reason, after trying to advise her for some time and forsaking her in bed without her being reasonable and getting out of options -if it is necessary-) as he flogs (beat or hit) a slave (if he committed an offence or was disloyal etc. and no other option seems reasonable) ... ."
And Allah knows best!