A bad spark plug can cause an engine misfire which could trigger the check engine light to come on.
Bad ignition coils or just one ignition coil that is bad can also trigger the check engine light to come on.
First though check to make sure your gas cap is not broken and is not loose and is on tight.
A broke, loose or missing gas cap can trigger a check engine light to come on and is a most common reason a check engine light does come on.
You can take your vehicle to Autozone and they'll plug their tool into your vehicles computer when the check engine light is on and will be able to find out why the check engine light is coming on.
Other things such as bad spark plug wires, or bad distributor cap and rotor if your vehicle is equipped with those can cause a check engine light to come on as well as low engine oil or even low transmission fluid.