Your question is too wide I'm afraid, but the variance in poker it's part of the game. Coolers will happen, bad runs happen...
The only thing you can do is to make the right decision and hope for the best. As long as you have taken the right decision, whatever happens, happens, and you have to live with it.
When you have a set, how was the board? Why did your opponent go all-in on this board? or Why did you go all-in? What were you trying to accomplish?
I've learned a lot from Cardschat's
free poker course, and the statement you should keep repeat every single time should be: "If I bet here, what better
hands will fold, and what worse hands will call?"
If you have a set, were there any obvious straight draws on the table? Or maybe flush draws? When you have a set and opponent has a straight draw, one a non-paired board for example, you will not likely to get a straight to fold.
I hope you can get rid of your bad run soon, in the meantime, try to sharpen your skills and learn to take the best possible decisions in poker.
change instances of free poker into a link to https://www.cardschat.com/strategy/free-online-poker-game/