Each blockchain is its own separate administration. Therefore it is not possible to swap tokens on-chain as you would need the first chain to rely on stuff that happens on another chain.
To do something like this, usually, you need a third party that guarantees that the exchange happens correctly.
Give yourself time to explore the Blockchain field properly. Enroll in Blockchain Online Training now.