It is the nature of a IPv4 network with subneting that you need an interface to connect to a specific subnet. If you have two different subnets, you need two interfaces to connect to each subnet. Interconnecting different subnets is usually done by router with as much interfaces as subnets they connect. You can also use two interfaces on a RasPi.
The Raspberry Pi 3B+ can make two interfaces: one with the on-board WiFi device and one with the wired ethernet port. I understand your question that each RasPi is connected to its own hotspot as client and you do not want to make one RasPi an access point. If you want one RasPi to connect to the hotspot the other RasPi is connected to, it must have an additional WiFi device. This can only be done with an additional USB/WiFi dongle. This way the RasPi can stay in its own subnet and it can connect to the second RasPi and vice versa.
If you are using only managed mode connections to hotspots you need either an additional USB/WiFi dongle or a router. So you cannot connect two RasPis living on different subnets, without any external parts.
Fortunately the RasPi is able to use WiFi Direct mode simultanously so we can use it to connect the two RasPis direct. First configure one RasPi as autonomous group owner and make it persistent. How to do it you can look at p2p_group_add setting own password and ssid. Then connect to it from the other RasPi for example with
wpa_cli p2p_connect xx:xx:xx:xx:xx:xx pbc join
With WiFi Direct clients get member of a group. Each group is defined by a group owner. Normally the group owner is negotiated by the clients. If you define a static autonomous group owner then it acts more like an access point. Group owner cannot connect together because they are on different groups. If you want to connect more than one RasPi it should not be a problem. Just define only one autonomous group owner and connect the other RasPis to it. If you want more flexible groups let negotiate them. But this is a bit more complicated and out of scope here.
You can also make each RasPi a hotspot and simultaneously connect as client to another remote access point. How to do it you can look at Access point as WiFi repeater, optional with bridge. If you like to spend additional hardware with an USB/WiFi dongle you can simplify the setup but it isn't essential. How to setup this you can look at Access point as WiFi repeater with additional WiFi-dongle.