I thought nodes could prevent this too. but if enough miners did do this, what could happen in worst case? thanks in advance for responding
To spend some BTC, the network’s nodes will require a valid cryptographic signature on the transaction that consumes the UTXO in question. Each UTXO is locked to some bitcoin address, and to create a signature that is valid for that address you’ll need knowledge of the private key used to derive/create that address.
So a miner is not in any sort of privileged position to spend coins that are not theirs, since they do not have knowledge of everyone else's private keys. No matter what a court mandates, the miner will be unable to legitimately spend coins they don't own. Any attempt to do so would be easily identified as cryptographically invalid.
A miner could start creating blocks which move arbitrary coins to addresses of the miner's choice, but these transactions and blocks would be rejected by the rest of the network of nodes, so it would be of no consequence to the network. The miner creating these fraudulent transactions would simply be ignored.
Each network node is an individual instance of the code, working to independently verify the state of the network. Even if every miner started to break the rules, the nodes would simply ignore them (and we’d expect some miner to eventually capitulate and start mining valid blocks again, since they will gain profit for doing so, and otherwise lose money by mining invalid and useless blocks).