Updated reply 11/26/2023; 06:22 AM
I don’t have any pinned apps. These are just apps that are open.
With the Enhanced taskbar off, the taskbar appears to pick up the icon from the folders I listed above.
With the Enhanced taskbar on, the taskbar appears to pick up the icon from the app itself.
This is my custom icon for Word. (see below)

With the Enhanced taskbar on, this is what I get when I right click Word on the taskbar. (see below)

This is what I get when I then right click word in the context menu. (see below)

And this is what I get when I click properties in the context menu. (see below)

As you can see above, my custom icon appears everywhere except where Word is open on the the taskbar.
It shows correctly on the right click context menu, the Properties window, and the Word Properties window icon on the taskbar.