Execute an extension from within another extension and return.execute_extension executes an extension like a macro then returns, whereas transfer does not return. When you don't need to do anything else use transfer and exit what you are doing and the channel goes back to the dialplan.
execute_extension will keep the current scope and build a one time extension, execute it, and return right back to where it was called from.
The transfer actually alters the channel's state, so if you are in a script you should exit the script as soon as you call transfer.
Note that this hunts through the entire specified dialplan, so all extensions in the target context are still checked for matches. Be careful to avoid loops and ambiguities.
If you do not specify the dialplan and context, it defaults to the current one. Please note that the extension parameter indicates a value that will be matched by dialplan_hunt() as a destination_number. It will not match on the extension's name= value. See the is_transfer example below on how to match on a name.
Another example is in features.xml: