It is possible, the search keywords are "synthetic fuels" or "e-fuels" ("electro-fuels). Currently it's a lot more expensive than fossil fuel, which is why it's mostly a research project and not a large-scale commercial business.
One problem is that while you can get an unlimited amount of hydrogen via electrolysis of water, you have to get the carbon from somewhere to produce hydrocarbons. There is a lot of CO2 in the atmosphere, but it's still a pretty low concentration so it takes a lot of energy to filter it out. And yes, using factory exhaust etc. is an easier option, but if we're gonna solve climate change most CO2 exhaust sources have to be replaced at some point so that might not be a very long term plan.
One problem is that while you can get an unlimited amount of hydrogen via electrolysis of water, you have to get the carbon from somewhere to produce hydrocarbons. There is a lot of CO2 in the atmosphere, but it's still a pretty low concentration so it takes a lot of energy to filter it out. And yes, using factory exhaust etc. is an easier option, but if we're gonna solve climate change most CO2 exhaust sources have to be replaced at some point so that might not be a very long term plan.