Whenever I go to a casino to avoid falling into these errors, what I do is basically allocate money that I am willing to lose, to be able to play and have fun, if I lose it, then I lose it, I assume it and nothing to do, but I don't try to search make money by making a deposit with money that I was not willing to lose
Exactly, this is the right thing to do and is the first gambling rule. Never gamble with something that you can't afford to lose. The moment you put something that you are unable to lose, your emotions will interfere with your logical decisions. It is also not possible to use your skill to turn the table in your favor. So it is better to just let it go.
But when money is on the line and even if it is something that you can afford to lose, you will still get affected by some emotions. It is hard to control in the first few tries, but with practice, we can control it to some extent. That is why it is important to learn to lose and start with low bets. Then when you master the art of controlling your emotions, move on to the bigger bids. This is the way to avoid chasing losses.