Good Morning Alex
Your question is shy on specifics, so I'll cover some broad things that can cause your engine to quit, or run roughly.
A running engine needs three things to arrive smoothly, and in a synchronized way: Fuel, Air, Spark. It also needs something to get it moving at the start, but you said it'll start, so I'll leave that alone.
If fuel isn't arriving like it should. Things to look at are:
- Old or clogged fuel filter. If it's been a while, or if you have no idea how long it's been since the filter was changed, this is usually an easy fix. New filter will have much less resistance to fuel passing through.
- Old or clogged fuel injectors. (Possibly a carburetor issue if the car is pretty old). If the injectors are clogged, not enough gas gets squirted into the cylinder. You can start by running a bottle of fuel injector cleaner through - add a bottle when you fill/top off your fuel tank. May take a couple tanks, and this won't help much if you can't keep the car started and running long enough to run the gas+cleaner through your injectors.
- Fuel Pump. A bit more involved, but the pump could be old, or, more importanly, leaking. A leaking pump, or fuel distributor, can be really dangerous. if you smell a lot of raw gasoline smell after trying to start, you'll want to get this tracked down ASAP - uncontained gas in an engine compartment can lead to a fire, big time car damage, and significant risk to your safety.
- Bad fuel. Sometimes you can run across a shady station dumping other (ahem) additives, or even water, into their big fuel tank. The wrong stuff can make your engine pretty unhappy. If the car has a preference for higher octane fuel, you might also consider a bottle of octane boost (most any car parts store). That might get you running and able to run the injector cleaner through and/or burn off the old or bad gas.
If there's no air, most likely you have a dirty / clogged air filter. Google for videos on how to change your air filter, it's usually pretty straightforward. Look at the current filter. if it's really dirty, or clogged with oily gunk, you'll definitely want to put in a new filter, and possibly try to track where oily gunk came from.
if there's no spark, it could be the coil(s) for the plugs being old, dirty, poorly connected to the electrical, or not attached to the plugs properly, it could be that the plugs are mis-gapped, damaged, disconnected, or fouled. Start by looking up the procedure to remove a spark plug on your make/model. Look at the electrode. Is it intact? Does it have the proper gap (you'll need a spark plug gauge). Is it covered in oily residue? (this may mean your piston rings are getting worn and letting oil into the combustion area). There are a lot of other possibilities and diagnoses - you can see more here
Spark Plug Analysis
Your manual will probably have recommended intervals to change out the plugs, it's not a bad idea if you're past that gap since the last change out. eBay is a pretty good place to get reasonably priced new plugs if the cost of the replacements is steep - (in my case, my Prius uses iridium plugs that can retail for $15-20 a piece, or were found on eBay for about $32 for the set of four)
pay attention to the part of the spark plug guide that talks about plugged PCV valves. This is another inexpensive part with a wide range of ease or challenge to replace on different engines. That may make a difference too.
Hoping that this may help!