Superconducting-insulator transition driven by out-of-plane carrier localization in Nd1.2Ba1.8Cu3O7+x ultrathin films