Global well-posedness for the 3D incompressible inhomogeneous Navier-Stokes equations and MHD equations