I see this a lot in videos from road bike races. A lot of rider team cars mixed with the road bikes doing the actual race.
What is the matter with that? What do they do? Also, don't the riders inhale all the fumes from the exhausts?
Motorcycles are mostly used for media (video and photos) and sometimes for support (they can have a limited number of wheels; I'm not certain if they are "neutral" or team specifics.
The motorcycles will be mixed in with the cyclists; the drivers are highly skilled.
The cars are for race support; there are team specific cars with spare parts and replacement bikes in case of breakage, and have team coaches and also used to transfer food and water bottles to the cyclists. I think there are neutral cars with spare wheels (maybe dependent on the particular races)
There are also neutral cars with doctors and race officials and VIP.
Most of the cars stay behind the cyclists; if there is a breakaway a car will (as safely as possible) stay with the breakaway.
As for the fumes; at the speed they are going, it is not an issue; and since there are only a few motorcycles mixed in the cyclists, I don't think it is an issue in itself; and the majority of the cars are behind the cyclists.
The convoy of team cars driving behind the riders are there to provide support to the cyclist, like food, clothing or mechanical assistance. The sequence of the cars is determined by the ranking of the riders, e.g. the general classification in a stage race.
During a race riders will drop to the back of the bunch (peloton) usually to collect new bottles from their team car. In such a case their car will drive to the front of the convoy. If they have a mechanical defect, they stop at the right side of the road and a mechanic in the team car replaces the wheel/bike. During this time other cars in the convoy will pass the stationary rider. Once he is on the road again he has to catch up with the peloton, often exploiting the draft of the vehicles.
The fumes of the vehicles are not really a problem at the speed the cyclists are travelling: the cars are well tuned and not using much fuel.