Realistically, at present most EV owners will not charge their cars from solar panels but from the utility mains and that means coal-generated electricity in many if not most areas.
Car manufacturing involves a tremendous investment of energy to mine and produce steel, aluminum, rubber, plastics, and electronics. Recycling itself consumes more energy, and in many cases raw virgin product is cheaper than recycled.
Not driving is impractical. Driving less, when possible, is worth considering.
Right now if you need to buy a car, the most environmentally friendly choice is probably a used (no new manufacturing) fuel-efficient conventional car.