Suppose a 20-person accounting firm uses a cloud PBX. An employee at extension 104 calls a colleague at extension 117. The PBX recognizes both extensions as its own users and connects them. The call needs no public phone number, and no carrier handoff is involved. Microsoft describes the same behavior in Teams, where calls between users in one organization are, by default, handled inside Teams and stay off the PSTN.
That does not mean the call stays inside the building. In this firm, both phones reach the provider over the office internet connection, so the call depends on that connection.
Now the same employee dials a supplier's ten-digit number. The PBX sees that the number is not one of its own and sends the call out through the firm's PSTN connection. The carrier on that connection passes it toward the supplier's carrier, and the supplier's phone rings. The PBX chose to send the call out, and the PSTN delivered it.
Incoming calls run the other way. The carrier delivers a call for the firm's main number, and the PBX decides whether the auto attendant answers or a desk phone rings.