Car shuts off while driving. Won't turn over and start... on 2004 Kia Optima

This vehicle was purchased from a family member and this is the second time it's done this. The first time they took car back and apparently put in New alternator and battery. This time vehicle stopped running while driving on why 17. The vehicle was towed and when the key is turned the lights and electric comes on but it won't start. How do I troubleshoot and find out what this could be.

Asked by for the 2004 Kia Optima
scan codes and post if any so we can adv
Don't have a scanner or way to get them
1 more answer , 2 more comments
When you say lights, do you mean the starter doesn't turn the engine? or is the engine spinning and the engine won't run?
I mean started doesn't turn the engine but we are getting power
What about the ground side. Check the engine ground from the battery cable and grounds to the body as well.