It should simply resolve in DNS and contact the CNAME that is being pointed to.
In the event it tries to contact the on-prem servers and they are not accessible on 443, it will try each of these URLs listed in the linked doc below:
However, with a CNAME ,it really shouldnt:
There is more info on the CNAME recommendation here:
https://learn.microsoft.com/en-us/Exchange/architecture/client-access/autodiscover?view=exchserver-2019#autodiscover-in-dns
Note:
Outlook 2016 and above will favor connecting to Exchange Online first: (Direct Connect)
You can change that behavior:
ExplicitO365Endpoint
So by default, the on-prem Autodiscover is not consulted.