"The question is: why are they investing in technology that is in inevitable decline vs. investing in the technology that will inevitably win?"
It can be profitable to invest in declining technology. Mazda almost by definition thinks it's profitable to still invest in ICEs. They can also invest in other drivetrains at the same time. The company can raise more money (assuming they can persuade investors).