I interpret the OP question to actually be two questions.
1. 5 cars essential to a work train
2.) 5 cars essential to a freight train.
To answer question one; it depends the era being modeled and on the type of work train ... wreck train ... tie and rail replacement train, general MOW work train that cleans up debris, clears culverts, ... weed sprayer train, ... or snow removal train. Most of these work trains would share some common cars ( ie: gondola, flat, and box cars ) while other cars would be job specific for the purpose of that train.
Again it depends on the era being modeled ( if any ) and the needs of your specific railroad. I don't want to impose my opinion on others. These are the cars I have ( and additional cars as well ) which comprise my work trains since I model the transition era 1946 - 1959/60.
To answer question two; the most common freight cars .. boxcar ... flat car .., gondola ... tank car. Of course the 6th common type of freight car being the hopper in both covered and open forms.
I've posted some photos of work train equipment on The Free State Junction Railway.
Big Hook for wreck trains and other types of heavy lifting.
Gondola car for carrying ties, booms, rails, blocking for the Big Hook, and other MOW equipment and heavy tools.
A short MOW train used for cleaning up debris alongside the track. A work caboose brings up the rear.
Tool and materials cars can have a multitude of purposes ... storage, machine/carpentry/electrical shop, office, bunk car for MOW workers, kitchen car.
Crane car with gondola being used as cradle for the boom. I do have a crane tender but no photos of it. A work caboose brings up the rear.
Snow removal trains are usually pushing a plow of one kind or another. Here is a flanger pushing snow. In summer months the flanger can be used to spread ballast on newly laid rail/ties. Rotary snow plow for those really pounding storms that leave mega depths of snow to deep for a flanger to push away.
Jet powered snow blower for blowing snow from switches. ( this car may be a stretch beyond my modeling era but I do like it )
A welding car.