That’s partly a manufacturer issue, a lot more difficult problem to solve than it may seem.
In my specific case the manufacturer is Microsoft. (It’s a Surface Pro.) There isn’t anything wrong with the battery. The gist of the issue is that there are milllion-and-one different things that can wake the computer from sleep, and then a couple of reasons why it might not automatically sleep again when ideal. If it was up to me, I’d have it so that the power button was literally the only thing that could wake it. But alas, I cannot even find a way to stop it from waking when opening the case (which I would like to do to check if it has woken up from some other reason).
In any case, I’m just saying that power management can be a problem in Windows (as well as in Linux).