iPhone is doing this online, sending data packet back to Apple.
Pixel is doing this completely offline.
I'll add another non-technical reason: ML is a Google core-competency, and has been for some time now[1], but it is/was not central to Apple.
1. Google 411 was introduced 13 years ago, in 2007, and look at the ML papers published and techniques Google pioneered since then.
iPhone is doing it on device as well.
Fairly certain that isn't true. On my wife's iPhone, she was never able to use voice to text while in airplane mode. Maybe that's changed with the latest 11 but it definitely didn't work on the X.
Go to Settings -> General -> Keyboards. If your language and phone support it, it should say "You can use Dictation for {language} when you are not connected to the internet." below Dictation Languages. It works since the 6s.