Why do new jet engines cost billions to design?
Even if we ignore the salaries of everyone involved; engineers, sales people, management, Q/A teams, manufacturing teams, more sales people, and then a few spare engineers...


  I don't understand. If it's just designing a jet engine, then raw
  materials cannot possibly be a major factor even if it's something
  like titanium or composites.


While the raw materials alone are not necessarily costly, the materials, as well as the machining and processing, can be quite costly. This can be further compounded if the engine uses some kind of new material for which there is no effective production method yet. This was the case for the entire production of the SR-71 Blackbird which needed to figure out how to work with titanium before actually building anything. Even once the bespoke parts are produced for a new engine the company will then need to figure out how to produce the parts in sufficient quantity to produce the engines for market.


  How many prototypes could you possibly need? I mean I hope it's not
  all trial and error.


It's not, but the FAA may require various demonstrations where they destroy the engine and you can bet the manufacturer is going to try that out before running any official tests. Once passed initial tests flying prototypes will need to be built and tested on real airframes that cost money, running jet fuel that costs money.


  The other thing is computer software, which I thought would make
  things easier and cheaper to design. Granted you cannot just input the
  desired thrust and press a button, but surely there is decent fluid
  dynamic software out there that can help you design something much
  easier and faster than before.


It makes some things faster, like FEM, and surely makes complex routing easier, but like a good wrench, CAD software is a tool that makes things faster and easier. It does not do the work for you.