Some animals can be very territorial. And hostile to strange humans they don't know.
But also, the squirrel initially might have been acting friendly. But the burglar, being surprised by a squirrel indoors, freaked. And the squirrel, frightened in turn, went into attack mode.
As for how the crook got caught, criminals have a pattern of stupid behavior that makes them attract the attention of the police. Maybe speeding in their car, running a stop sign, who knows. Once pulled over, the Officer noticed the bleeding hand, as was stated, And perhaps a load of loot in the back seat. One thing leads to another.
Funny story, though. Nevertheless, I don't think I'll be bringing any squirrels into our own home.