Someone guilty has done something wrong or illegal. And when you do something wrong, you feel guilty — bad or sorry — about it.
The police are responsible for finding out who’s guilty of a crime so they can be arrested, convicted, and punished. But you can also be guilty of smaller, more legal things, like cheating on a test, breaking the rules of a game, or thinking awful things. If you’ve done it, then you’re guilty of it: so if someone asks if you have a crush on your swim instructor, you can say “guilty!”