It's complicated and honestly I think there have been discussions over the years as to what you should really be using and even MS doesn't agree. There are several factors going on here and which value is being retrieved by which command/tool/UI is an implementation detail so I don't know that I'd try to figure it out. Choose the one that lines up with what "you" believe it should be.
Things that can impact the edition queries. If you initially installed one edition but then upgraded/downgraded to another then the edition shown may not be the same. The WindowsEditionId
comes from the registry and I would think is the most accurate but I could be wrong. You could test this scenario though.
Another thing is the licensing. You have an edition and a product key/subscription tied to it. They don't necessarily line up. Most people install Pro and use a Pro license but you can install Pro and use an Ent license and Windows doesn't care. AFAIK you cannot go the other way though but I honestly have never tried. Furthermore MS 365 Business subscriptions throw another kink into the plan. From what has been reported online, the WindowsEditionId
represents the actual Windows edition installed but the UI (and perhaps other tools) show the edition as Business
even though this isn't actually an edition of Windows.
If it were me personally I'd lean toward sticking with WindowsEditionId
even if it doesn't line up with the OS name. The OS name, to me, is a UI display thing and may or may not be accurate. But you should probably base your decision on your own testing.