These USB-C Intel Mac laptop have some quirks. An occasional issue like this happed from time to time. If it happens a lot, then that indicates a problem.
Did you perform a clean install of macOS by first erasing the whole physical SSD followed by installing macOS?
Did you test that configuration before installing any third party software or restoring from a backup?
What is the battery condition according to macOS?
FYI, to make sure these recent Macs are completely powered off, I like to press the Caps Lock key before selecting Shutdown. When the Caps Lock LED goes dark the laptop should be completely powered off (or asleep if Sleep was selected).
Guy Burns wrote:
After several hundred boots over the last two weeks, this machine still won't start reliably. It has a new install of Ventura; PRAM and SMC have been reset now and again; but sometimes it starts, sometimes it doesn't.
The latest hiccup went like this. Machine was turned on and functioning with power connected. Closed all open software, shutdown, closed lid. Several hours later, I lifted the lid. Nothing happened. Closed lid, waited a minute, and lifted. Nothing. Repeated a few times. Nothing.
Connecting the power adapter would be advised. You should hear the "ding" within a minute or two if the unit is receiving power, although I have seen a few systems where it took 15 minutes before I heard the "ding" & the laptop powered up. Also try each USB-C port especially on the other side of the laptop.
If the power adapter is already connected, then disconnecting the charging cable & reconnecting the charging cable can be enough to trigger a system power on.
So I tried the cold treatment (room temperature at the time was about 20ºC). Disconnected power, put the laptop in the fridge for 5 minutes, opened lid (without power connected) and it booted. Talk about exasperating!
Absolutely no reason to do this. If anything you will make things worse. If the laptop powers on then you have a much larger temperature differential on the electronic components which heat up rapidly so you are introducing thermal stress on the physical hardware since some items will physically expand faster than others causing stress fractures. Plus there is a potential of introducing liquid into the laptop through condensation.
What could the problem be? Anything to do with disconnecting the power? Loose wiring somewhere? Faulty "Open lid" switch?
All are certainly possible (loose wiring not so much except for the battery flex cable). The sleep sensor is a magnetic sensors which typically doesn't fail unless damaged by liquid. Only the 2019+ models have changed to a worse solution involving an unpredictable Lid Angle Sensor that seems much more prone to issues.
There are a lot of possibilities with the 2017 models including a bad internal display cable that has a high rate of failure. The USB-C ports on this model are also known to wear prematurely resulting in loose connections with USB-C cables. I also suspect an unknown hardware issue with the Logic Board which ends up losing the connection to the battery which ends up showing the battery icon to indicate needing to connect the power adapter.
You neglected to specify the exact model.....15" or 13", Touchbar or non-Touchbar.
@kaz-k's guess is a very good place to start. However, I have seen lots of battery failures where the Battery Condition is still "Normal" and the Apple Diagnostics pass. Age does play a big part in the health of the battery. Plus some of the non-Touchbar model has a known battery issue as Apple at one time had a free battery repair program for it (now expired).