In the US this is legal. Banks are authorized to repossess property if you’re late on a payment^. Private companies are allowed to participate in repossession as long as they don’t break any other laws. Tesla didn’t break into the owner’s house to steal their passwords or keys, they didn’t assault the owner. All they did was take his car. They verified that they were taking the correct car. Since the repossession was being carried out on behalf of a bank, there was no theft. This is completely legal. If you don’t want a car company to assist a bank with repossession, don’t get a car with remote access features- which pretty much means an old car.
^There are rules on how late you have to be though- it’s not like they are taking your car after you’re 1 day late for the first time. The required amount of lateness depends on the state. And they are only allowed to take property that was used to secure the loan. In the case of a car loan that is usually the car itself.
It doesn't go through the judiciary (e.g., it would if it were an an apartment and you stopped paying rent), but the owner signs a loan note that specifies that the loan is in default after missing N payments (usually after 3 months). Once in default, the bank can repossess the vehicle, but they'd rather not since their business is lending money and anything else is a money-losing distraction. So they will usually try to find a way for you to keep the car (and keep making payments). They usually only repo if they can't contact the debtor or they can't come to an agreement.
Repossession of any kind (car, house, etc...) is typically an option of last resort for the bank after the debtor refuses to work with them or enter into other agreements that could help. They really just want to keep collecting payments from you.
The other big thing at play here, is that car lenders get about 1/3 of the expected loan value if they repo the vehicle. Most of them don't want to do it unless they have to, it's usually far more profitable if the consumer continues making payments.
The court typically only gets involved if the lender has reason to believe you might do something malicious and can convince the court to execute an immediate right to seize the vehicle (quickly after default). A court can also order a person to return the vehicle, if they've managed to successfully evade the repossession action by hiding it. This is a good thing so long as it's reasonably balance (ie the consumer doesn't get their vehicle repo'd on day one of being late), so our court system isn't filled up with car loans.
^There are rules on how late you have to be though- it’s not like they are taking your car after you’re 1 day late for the first time. The required amount of lateness depends on the state. And they are only allowed to take property that was used to secure the loan. In the case of a car loan that is usually the car itself.