The majority of gamblers are not stupid, and know full well that the odds are stacked against them. It is their lack of self-discipline that makes them stick to their bad habits. The bottom line is that gamblers lose money and there is nothing anybody can do to change that. But some people, on the other hand, will persist in gambling regardless of their losses. They are enjoying the "high" of winning and therefore they continue gambling.
Don't get me wrong, I am not advocating against gambling, but many people – including myself sometimes – like gambling for its thrill. We like games and risk. It is part of the human nature, but we have to know how to balance it in our lives and always be cognizant of the dangers.
This is a difficult theoretical question
The problem is that "knowing the right thing" and "doing the right thing" are so different things that sometimes they don't intersect at all. Therefore, "not stupid" gamblers, who seem to understand everything, nevertheless make childish mistakes. This happens for various reasons, but also because being "theoretically" smart and acting smart in practice are two different things.