can be the fuel cap is not venting, or the tank outlet is plugged and letting it sit for a few seconds the carb fills back up. It can also be a wire that is killing the spark and the act of shaking the engine when pulling the cord moves the wire that it runs until it shorts out again. It can be that a valve is tight and it sitting for a minute it cools enough to close and the engine get compression again until it heats up. I certainly would not buy a new engine under these conditions. I'd find and fix the problem. And I would not rule out bad fuel. I had a boat motor do that once over and over and over until I changed the fuel. On a two stroke engine, which you probably do not have, a crankcase seal leaking can cause that. Most likely you have a 4 cycle engine with gravity flow fuel. A plugged exhaust can do that too. Especially if there is a spark arrestor on it that is carboned up, or mud daubers have built mud nests in the exhaust, blocking it.