As correctly stated in the reply above, this is not a problem with the macOS and iOS configuration.
It’s entirely the Wi-Fi router.
Your Wi-Fi router controls what connections are permissible (can be routed) between a guest network or guest VLAN and the main network or main VLAN.
IP routing is centrally involved here, and client-to-client connectivity (sometimes called client isolation) can also be involved where that feature is separately controllable.
I am here assuming the rationale for the guest Wi-Fi is for a more easily changed password, and for a network “off” switch, as the guest network is not otherwise providing much in the way of security. This I would typically not expose my main network to nor expose a core Mac to a guest network.
More help with this? Check with the folks that know the details of your particular Wi-Fi router best.