My riding mower (17 yr old craftsman), stared acting that way when I took it out of winter storage early this year.
After a lot of troubleshooting, I found the fuel shutoff solenoid was sticking.
This is a small barrel shaped thing with one wire on it. It screws into the bottom of the carburetor. When solenoid is off, gas is cut off to the jets.
I unplugged the wire, screwed it off the carburetor, took out the little plunger, washed it with carb cleaner, flushed out the solenoid as best I could, wiped it all down and re-installed. Running like a champ ever since.
I used cheap gas a couple of times last year. Big mistake. I now use only good grade non alcohol gas. I usually always use the good stuff but i had one of those days last year when I was in a big hurry and the convenience store is a lot closer than the good gas station.
Now yours may or may not have the fuel shutoff solenoid.
Also if its a new mower I would take it back. If you try to fix it yourself you may void the warranty.