Just because you are wrong about your expected value calculations (or were right but the actual return was on the lower end of the range) and have made a bad investment doesn’t change the fact that it was an investment because you were doing it for the returns.
In short, performance doesn’t matter for this distinction, at least IMO.
The DJIA (e.g.) isn’t “the house”. It isn’t something you are competing with in that your losses are its/their gain. You are misunderstanding both investing (in general and the stock market specifically) and gambling when you make that confusion/analogy.
Not beating the market but having positive returns is only “losing” when infinite exponential growth is the goal. Beating the market but having negative returns is not “winning”.