Well, if you generate an address and some coins were already there and you use those coins, then it's illegal.
Let's make this even more simple.
Suppose, you generate a private key and somehow it turns out to be the private key of a very large exchange. You transfer those coins to your address. Then the exchange announces that it got hacked and will take legal steps against you. So there you have it, it's illegal
If that happens though, well, just don't steal 'em. It's illegal and morally unacceptable. And if I am in that situation, definitely I will try to contact that address holder in different possible ways. But most of the bitcoiners keep their bitcoins in cold storage and finding them is a highly hard task.