If you have driven through water and the check engine light in your vehicle comes on, you should take your car to your mechanic. You will want to have your vehicle checked for any damage caused by the water.
Probably will find that the ignition (plugs, wires, etc) got wet and triggered a misfire code (P0300). Allow the system to dry thoroughly and when the system detects there is no misfire after a few drive cycles the check engine light will go out.
You will need to have a technician scan the computer for codes. It is very possible that you have an oxygen sensor problem.
the check engine light will come on and off and the vehicle will not shift through all the gears properly
If you can hear a click from the starter, but it does not spin, you may have sucked water into the engine. That can destroy the engine. You need to remove the spark plugs to check for water in the cylinders.
engine stalls sometimes driving
Check your sensors.
The Check Engine light comes on when the ECU detects a problem with the emissions system. Seek professional help.
Check engine most likely
Assuming your driving is not to blame, and theres a fault with the car, then yes its likely to be a fuel problem. Check the engine management system on newer cars with your dealer. Check there's enough fuel in the tank! Check the fuel pumps and filters. A blocked filter will restrict the amount of fuel flow. Check the fuel injectors. If they are blocked with carbon, the engine will likely struggle.
If the check engine light is flashing as you are driving it means you are about to destroy the catalytic converter(s). Stop the engine and get it to a garage.
Check engine oil when you have just finished driving. Check Transmission fluid when the car is running and the transmission in in N (manual) or P (automatic).
Go to Auto Zone and they will check you engine light for FREE... And go from there...