Google is very good at recognizing existential threats. iOS were that to them and they built Android, including hardware, a novelty for them, even faster than mobile incumbents at the time.
They're more than willing to expand their moat around AI even if that means multiple unprofitable business for years.