Contractors have cash flow problems for two major reasons: poor money management, and poor payment schedules.
Poor money management usually involves ignoring the budget when making purchases. The best example is buying a vehicle on short notice. Vehicles almost always provide warning that they are about to quit running, so it's pretty rare that you need to purchase a vehicle immediately. Another example of poor money management is overpaying owner's salary.
You should make your overhead projections at the end of each year and if something is not on the budget for the year, you don't buy it. And if your sales and profitability are below budget, your overhead expenses also need to be less than budgeted.
The other issue is payment schedules on contracts. Time and again I find myself explaining to contractors why the 1/3, 1/3 and 1/3 payment schedules won't work. This payment schedule has the contractor paying for the job out of their own pocket. Down payment, progress payments about every 2 weeks and a final payment of no more than 2% of the sales price of the job keeps the job paid as you go and helps keep cash on hand to pay the bills.
If you are working as a subcontractor to a larger contractor or working for the government, read their contracts carefully. They are almost always written to your disadvantage with payment schedules based on when they get paid or feel like paying you. They also throw in that little thing called retainage. If you get involved with those contracts, unless you can get them to pay you on your time frame, you'll have to live with poor cash flow during those jobs.
Know your cash flow needs, make a plan and keep it, and write contracts with payment schedules that are win-win. It makes life much easier.