You should buy a car before you desperately need one. This gives you time to research different makes and models, as well as allowing you to wait for incentive periods at the dealership. The internet may be an excellent resource for research.
If you are buying a new car, or a car from a dealership, it can be good to go car shopping around when the new models are coming into the dealership. The next year’s models often come into the dealership any time between August and November, and dealers will be trying to clear this year’s models.