One of the techniques is called buffer overflow. Where you target a flaw in some software. Computers are logic, they will do EXACTLY what you tell them. Imagine if an image viewer uses an dll to process jpg. That dll expects a very specific header. If this is not handled correctly and a malicious attacker crafts the header to be slightly larger and the larger part contains executable code. This code spills over in the adjacent memory area. The OS then reads this as code to run… and boom you are in.
This is oversimplified and proberly not explained correctly, but its something like that; and that kids, is why its important to update your OS and software.
Sometimes they find bugs like this, that have existed for many years before being discovered.
And you “own” it only as long as they deem it. https://nofilmschool.com/warner-bros-deleting-purchased-digital-content