If you install windows on a machine that already has ubuntu, it will overwrite the MBR (Master Boot Record).
This is a guide that will allow you to keep boot priority on ubuntu (EFI)
grub-install onto the device that you installed ubuntu on (don't specify partition e.g. /dev/nvme0n1)
sudo grub-install /dev/<device_with_ubuntu>
typically it will have GRUB_TIMEOUT_STYLE=hidden
and GRUB_TIMEOUT=0
# /etc/default/grub
...
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=1
...
Then run the update command
sudo update-grub
# /boot/grub/custom.cfg
menuentry "Windows (UEFI)" {
search --set=root --file /EFI/Microsoft/Boot/bootmgfw.efi
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}