Found it. Finally. I am not 100% sure, though.
My theory says: It’s the coexisting, “normal”, Windows installation that happens to be on my system. Upon initialization, MSYS2 swipl correctly searches for packs in the msys2 folders; later, it also looks into the Windows folders. As it finds some packs there, the Windows folders are added to file_search_path(pack, X).* The problem disappeared after I removed c:\users\matth\appdata\local\swi-prolog.
*which, probably by the way absolute_file_name/3 works with pack(.), puts the windows folders in the beginning of the “pack” search path.
One way to solve it would be to change the behavior of prolog flag xdg:
\definition{Flag is not defined}
First search the Windows directories, then the XDG directories. This is the default for the Windows binaries.
\definition{Flag is \const{true}}
First search the XDG directories, then the Windows directories. This is the default on MSYS2 and Conda.
→ change to Search the XDG directories only.
\definition{Flag is \const{false}}
Search the Windows directories only.
I should add that I may not see all the implications of this patch.