Here's the thing: It's quite, quite unlikely that someone is hacking your webcam. The most likely scenario is that some program in the background that you didn't realize you had opened before, was using it. Or maybe a game was using it, some games for some reason use the webcam.
But if they have access to your webcam they have access to your entire system. So if they do have access to your webcam, your webcam is the least of your worries. Do a malwarebytes scan as others have said. If the problem persists and you're *1000% absolutely no-doubts-at-all certain* that it's not a program doing it, then you can reinstall windows or something along those lines.