EDIT- After further testing: While both code snippets above worked in 3.28 on Ubuntu 22.04, I found a similar behaviour to that described by the OP in 3.22 on Windows though only when running the code in a new, empty project.
A workaround is to load the layers in two separate functions and call the second function from the first, using QTimer.singleShot
to apply a small delay.
from pathlib import Path
from PyQt5.QtCore import QTimer
import requests
def load_raster():
image="/media/patrice/DataDrive/GORiM/ManualFineTuning/GEE/S2_S025_Z12R.tif"
Cname = Path(image).stem
Zone = Cname.split('_')[-1]
rlayer = iface.addRasterLayer(image, Cname, "gdal")
iface.setActiveLayer(rlayer)
iface.zoomToActiveLayer()
def load_basemap():
service_url = "mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}"
service_uri = "type=xyz&zmin=0&zmax=21&url=https://"+requests.utils.quote(service_url)
tms_layer = iface.addRasterLayer(service_uri, "Google Sat", "wms")
QTimer.singleShot(100, load_raster)
load_basemap()