So most of the costs should end up as salaries to engineers.
Even in a project that is solely people-based, most of the costs do not end up as salaries to engineers. Salary is typically a bit less than a half of the cost. Those engineers get benefits. Health care in the US isn't cheap. They get holidays, vacation, and sick leave. They receive matching funds on their 401K contributions. In the US, employers and employees both contribute to the
cesspool lockbox sometimes known as "Social Security". The employer share is part of the cost of having an employee (and companies charge for it). The employer also pays for unemployment insurance and other items on behalf of their employees. Those engineers sit at desks in an office or a cubicle, and have a nice computer on which they do their work. They use the employer's servers, printers, copy machines, conference rooms, break rooms, and coffee machines. All of that costs money. These overhead costs are the first of several indirect costs.
The accountants who write those engineers their paychecks aren't charging to any project. They're still paid by the company, as are the executives of the company. The executives also typically don't charge their time to a project, and those executives can be paid quite handsomely. This leads to another category that adds to quantity that companies charge the government, "general and accounting". Finally, for-profit companies need to keep their shareholders / stakeholders happy. They need to earn a profit. This leads to a third category that companies charge the government, "profit".
When you add up all of those indirect costs, they come close to and oftentimes exceed direct costs (i.e., chargeable salary). Note that this is for a project where the only costs are the people working on it.
Building a spacecraft notches things up a lot. Cleanrooms are expensive. Control rooms are expensive. The flight computers are expensive. The bolts and fasteners are expensive. The custom, one-off sensors are expensive. The spacecraft's thermal control system is expensive. The spacecraft's structure is expensive. Launch is expensive. Every piece of hardware, every fabrication facility is expensive.
Finally, cost overruns, requirements changes, and delays can represent a significant portion of the cost of a poorly managed project. JWST has experienced numerous cost overruns, requirements changes, and delays. Big contractors have learned that the only way to win big government contracts is to underbid. They would lose their shirts if the government kept to that initial contract. But it never does. The government instead changes the requirements, changes the payments, and changes the schedule. Those changes are beyond expensive.