So this problem gave me a lot of headaches. Maybe this post will save time for others.
In order to be able to install Ubuntu Touch using the UB Ports installer, you have to start from stock Android (https://developers.google.com/android/images#hammerhead).
Normally, all you have to do is to download the latest firware for Nexus 5 from the link above (Android 6), extract on the desktop running Windows its contents and doubleclick on flash-all (Windows Batch File).
However, if you have previously installed newer custom roms, such as Unofficial LineageOS based on Android 11(https://forum.xda-developers.com/t/rom-unofficial-lineageos-18-1-for-nexus-5-hammerhead-discontinued.4214367/), you may need to revert back to the stock partitioning.
Information can be found here: https://forum.xda-developers.com/t/recovery-unofficial-twrp-hh-for-nexus-5-hammerhead-discontinued.4047653/
In this case, when I installed this custom rom I had to use a special customized TWRP, namely TWRP HH.R.
In order to install Ubuntu Touch in this case I had to revert to the stock partitioning, please see at the link above:
``How to revert back to stock /system size and stock partitions map:
- Launch HH.R version of TWRP
- Open terminal (TWRP -> Advanced -> Terminal)
- Type hh_repart -r
- Wait until your phone reboots
- Flash official TWRP or HH.S version of TWRP! Don't ignore this step!``
Afterwards, I installed the stock rom as described above and the UB Ports worked perfectly.