I think in gambling there is no assurance that we will not going to lose money. If we really don't want to lose money then stop playing gambling. But of course it is a hard decision for those who are already addictive. But in my own opinion, there is no assurance that we will not lose money in terms of gambling.
In gambling, you have to expect the unexpected. You might earn a lot of money and lose a lot of money. There is really no guarantee but you have to limit yourself when it comes to gambling or just stop for a while when you already have enough profit.
Limiting yourself is only way to be sure and not lose all the money you have. That would be the basic bankroll management and you can find many articles, videos, books, interviews with professional gamblers that talks about how they manage their bankroll.
You need to know how much you have, then you need to split that amount on how many bets you wish to make, I don't wish to confuse you, bankroll management is difrent for each type of gambling, casino games are one type, then table card games like blackjack and Caribbean poker others, poker is hardest because in poker you play against other people, and that can be very unpredictable.
The best is to choose the game you like and then to read and learn how to manage you bankroll for specific game you like.
well losing is part of gambling, the only thing we can do is maximize the winnings and minimize the loses, limiting and being responsible can make those things possible. Losing may happen but we should learn from find ges that suits your interest for atleast you can felt the thrill and happiness.