How to know when a recipe shouldn't contain onion/garlic?
Bolognese is (to Italians) a specific dish with a precise ingredient list. You wouldn't put garlic in a chocolate cake, but that's because it probably wouldn't taste nice. Imagine a chocolate cake to which you added coffee. Some people might enjoy the cake, some might not, but assuming it was a cake and had plenty of cocoa and/or chocolate, nobody would say it wasn't a chocolate cake. Now imagine you made a Tarte Tatin but you used pineapples instead of apples and you added chocolate, too. Some people might say "this isn't really a Tarte Tatin" because you're not following the traditional recipe for that pie. That's how they are feeling about the Bolognese sauce.

I expect that to you "Bolognese" means a vague category of tomato-and-meat sauce for putting on pasta, and you figure you can put in whatever you like as long as you like it. The Italians aren't complaining because garlic ruins the taste, but because when the sauce has garlic in it, it's not really a Bolognese any more, just as a Tarte Tatin with chocolate and pineapple isn't really a Tarte Tatin any more.

So the literal answer to your question is: garlic and onions do not belong in any dish that has a capital letters name and a generally accepted traditional recipe for that dish, where that traditional recipe doesn't include garlic or onions. If the dish doesn't have that kind of name (eg beef stew, grilled steak, roast chicken) then you're free to put in anything you like. It's not a matter of "not needed" or not, but of following a particular recipe or not.

As for the Bolognese with garlic, you could call it precisely that. Or "tomato and meat sauce with garlic." I bet it was yummy.