My camera spins upwards or downwards while playing

It started happening today, in the middle of a custom game. My camera spins upwards or downwards repeatedly, out of nowhere and when I was tabbed out but still in the custom game with Overwatch open, I see that my cursor snaps to top left or the bottom right corner of the screen, does anyone have a fix for this?

EDIT: The cursor still snaps sometimes when I don’t even have the game open, but it is does it rarely and doesnt do it as much as while in game tho, I think it is most likely to be a problem with my mouse settings