You need to find out what your personal triggers are - they'll have been different for all of us.
If it's related to drinking/ smoking, diet, weight - there is an easy solution to that.
If it's related to personal circumstances, change what you can change to improve your life - get divorced, change jobs, move house,...
If nothing logically sets it off in a predictable pattern, get CBT and a full physical check-up to find out the reasons. Sometimes it's hard to recognise your triggers without external help.