How long does your MacBook Pro take to goes automatically shut down after you put it to sleep? When your MacBook drains the power, it naturally shuts down. But if your MacBook randomly shuts down when there's enough power, it is not a common thing.
You can check if the battery can hold the power for a normal or relatively long period. If it can't, the battery probably has some issues, making the power being used too quickly. You can contact a local repair store to fix it. And I have to note that, as your MacBook Pro starts to shut down by itself after being in sleep mode, you'd better back up the files on it in case your MacBook won't turn on some day in the future.