It's not just ignorance, some people just have a tendency to think that laws don't apply to them, that they are special and have luck, and they surely will win. So, a person can understand that the odds are against them, and still gamble like crazy because of their superstition. I think this is far more common than not understanding the math behind gambling.
That's true, irrational behavior is a big part of it but that's a bit different issue and it also involves self-control, addiction, and other problems. My focus here is those who just don't know and there are many people like that. There is no knowledge test that one needs to pass before starting to gamble, and casinos may show some generic legal text about "games of chance" before opening the account but they don't really tell their users "YOU WILL LOSE!!!" - might be bad for business. That's where all sorts of scammers come in, trying to sell scripts and strategies to misinformed/underinformed gamblers.