> Not everywhere in the world do companies count as people
Actually yes, everywhere in the world. That has a functioning legal system, at least.
If companies weren't treated as legal persons, they wouldn't be able to enter into contracts.
But also, just to be clear, a legal person, like a corporation, is not a natural person. Unlike a natural person, they can't vote. There isn't anywhere in the world that considers corporations to be natural persons.
Laws are different in different counties, and I can't speak to all of them, but in the US, the law said you could only sue people, and the courts realized this was a problem. Rather than saying "I guess corporations get are exempt from all liability until Congress gets around to fixing it", they came up with a weird workaround that lives with us to this day.
EDIT: Note that ianal, nor a historian. The specifics of how this came about are best learned from a more authoritative source.
Not everywhere in the world do companies count as people, yet they can still be sued.
I'd wager the companies lobbied for this to gain extra rights.