Role of THF in oxymercuration of alkenes
$\ce{THF}$ is a polar aprotic solvent, that is, it can stabilize positive charges but not negative ones since it won't form hydrogen bonds with the help of any of its own hydrogen atoms.

Thus the carbocationic intermediate, that is the mercurinium ion is still stabilized, allowing the reaction to proceed.

And in Hydroboration, $\ce{THF}$ acts as the solvent as well but plays the additional role of shifting the equilibrium between diborane and borane to the side of the latter. As you might know, the Boron atom of $\ce{BH3}$ is electron deficient, which plays a key role in the formation of the trialkylborane intermediate of the Hydroboration reaction. Formation of diborane quenches this electron deficiency of borane by the formation of two 3-centred, 2-electron bonds in the dimer.