The bug
Horses, donkeys, mules, llamas and camels all use the file textures/gui/container/horse.png. Not only is this intuitive by name terms, it's also inconsistent with:
furnaces, blast furnaces and smokers, which all use different texture files despite appearing identical
shulker boxes, which have an identical looking inventory to single chests/trapped chests, ender chests, barrels and minecarts with chests, but are handled by a dedicated texture file
How to fix
Introduce new, dedicated files for each of these entities.
Further notes
Fixing this should also make fixing MC-265033 easier - for the type of entity in question, the saddle/carpet/armor slot could be made part of the inventory texture itself rather than an external sprite, and the slot outline could be split into its own file as to behave correctly when items are in the slot.
Can confirm with code analysis of 24w14a.
The resource location of the inventory:
The code which controls how the 'horse' GUI should behave depending on which entity is being ridden: