It was a plausible reason for Moody to turn Draco into a ferret.
Barty Crouch Jr. didn’t necessarily actually care that Draco attacked Harry when Harry’s back was turned. (It’s possible, though, that he did, but either considered an opponent with their back turned different to being outnumbered, or was simply a bit hypocritical.) However, it would certainly be believable that Moody would care about something like that. Barty was playing a character, and for him to be able to take any action, especially so publicly, it would have to be something that Moody would plausibly do. To turn Draco into a ferret, he’d need a reason that people would believe for Moody to do it.
Doing it ensured Draco didn’t hurt Harry, who he needed to win the Tournament.
It was certainly in Barty Crouch Jr.’s interest to keep Harry safe, and therefore stop Draco before he could do any serious damage - he needed Harry to be well enough to win the Triwizard Tournament. He couldn’t afford Draco possibly doing enough damage to Harry that he wouldn’t be able to win and fall into the Dark Lord’s carefully set trap. He explains to Harry that he made sure to scare off anyone that would hurt him or possibly stop him from winning the Tournament, which would include Draco trying to attack him from behind.
“Who put your name in the Goblet of Fire, under the name of a different school? I did. Who frightened off every person I thought might try to hurt you or prevent you winning the Tournament? I did. Who nudged Hagrid into showing you the dragons? I did. Who helped you see the only way you could beat the dragon? I did.”
- Harry Potter and the Goblet of Fire, Chapter 35 (Veritaserum)
The first thing he did after transfiguring Draco was check to see if he’d successfully hit Harry. His priority was making sure Harry remained intact.
“Moody turned to look at Harry – at least, his normal eye was looking at Harry; the other one was pointing into the back of his head.
‘Did he get you?’ Moody growled. His voice was low and gravelly.
‘No,’ said Harry, ‘missed.”
- Harry Potter and the Goblet of Fire, Chapter 13 (Mad-Eye Moody)
He probably enjoyed it since Draco was the son of a free Death Eater.
Barty Crouch Jr. would have likely held a grudge against Draco, since he’s the son of Lucius, a Death Eater who went free and didn’t use his freedom to seek out the Dark Lord. He probably saw an opportunity to have a bit of revenge on the son of a traitorous Death Eater, while still remaining in character as Moody. However, it’s equally important to note that Barty Crouch Jr. wouldn’t have acted on his hatred if it didn’t make sense (both as Moody and in furthering his own plot) since he never attacks Draco, Snape, or Karkaroff in any other situation. His main reason was almost certainly making sure Harry could still win the Triwizard Tournament.
“I told you, Harry … I told you. If there’s one thing I hate more than any other, it’s a Death Eater who walked free. They turned their backs on my master, when he needed them most. I expected him to punish them. I expected him to torture them. Tell me he hurt them, Harry …’ Moody’s face was suddenly lit with an insane smile.”
- Harry Potter and the Goblet of Fire, Chapter 35 (Veritaserum)
Moody turning Draco into a ferret would have also helped ingratiate himself to Harry, who he needed to earn the trust of so he’d be more willing to accept Triwizard Tournament help.