Diffie-Hellman and RSA are distinct and do not use the same "trick".
In Diffie-Hellman, commutativity is used: $(g^a)^b = (g^b)^a$. Both Alice and Bob do two modular exponentiations each (Alice chooses $a$, computes $g^a$ and sends it to Bob, receives $g^b$ from Bob, and finally computes $(g^b)^a$). Security relies on the difficulty of discrete logarithm: given a prime $p$, an integer $g$, and $g^x \mod p$, it is utterly difficult to find $x$.
In RSA, there is no commutativity involved; Alice and Bob do only one modular exponentiation each; computations are not done modulo a prime $p$, but modulo a non-prime $n$. Alice chooses a random $m$, computes $m^e \mod n$ and sends it to Bob; Bob computes $(m^e)^d \mod n$ which is equal to $m$ because $d$ and $e$ have been chosen for this to work. RSA relies on the difficulty of extracting $e$-th roots: given $n$, $e$ and $m^e \mod n$, it is utterly difficult to find $m$ -- unless you know the "magic trap", i.e. $d$ (or the factorization of $n$)(if $n$ was prime, finding $m$ would be easy).
Although both algorithms involve modular exponentiations, they are quite different in how they work, what they provide, and what hard problems they rely on. Note the difference: in discrete logarithm, you have $g$ and $g^x$, and seek $x$; in $e$-th roots, you have $m^e$ and $e$, and seek $m$.
Any asymmetric encryption algorithm (such as RSA) can be used as a key exchange algorithm, in the way you describe (to "exchange" a key, Alice selects a random blob and encrypts it with Bob's public key). SSL/TLSSSL/TLS does that. The converse is not true: you cannot generically transform a key exchange algorithm "alone" into an asymmetric encryption algorithm (but you can use the exchanged key with a symmetric encryption algorithm like AES; there again, SSL does that when using Diffie-Hellman).