Many investors lose money not because the stock market doesn't work, but because they make avoidable mistakes.