DRM aka Digital Rights Management is a technology that enables online video and audio content providers to make sure that their services are being used the way they want it to be. Okay, now don't get too excited there, they are not hacking your device! In fact, DRM is a preventive measure towards piracy. In other words, DRM limits the things a user can do with the content a service is offering.
For example, DRM is the reason behind why you can't just download a Netflix movie onto your media drive and use it later without paying for the subscription, and also you might have noticed that you cant record your mobile screen when you are watching a Netflix video. This ensures that the content is not shared "illegally" on third party websites. Although hackers did figure out a way to get around this but they generally don't offer the same quality of content as the genuine copy. So, play it legal folks!
How does it work?
Well, DRM isn't a new thing, in fact, it has been around for a really long time, floppy disks also used to come with copy protection, although in older media like DVDs, DRM worked as a pair of encryption-decryption keys, the DVD drive will have some kind of encryption that means the content of the drive will be scattered around and the DVD player will have a decryption key that will put the pieces together. Although, of course, hackers can find a way to get around it.
Well in the modern versions DRM uses dedicated encoding, packaging, playback, and license servers. Most services achieve this by binding a specific purchase to an account and then verifying each time with a remote server that the specific account is authenticated before playing the content or even downloading it. This is the reason Netflix or Spotify needs you to log in to your account before letting you stream anything.
Now, when it comes to physical media like blu-rays, and DVDs they are still stuck in that encryption-decryption age, of course with better encryption techniques nowadays.