If you know exactly what you want, it can be cheaper to buy everything in parts. If you don't, buying a whole bike is often cheaper.
The trade-off is that a complete bike may still require parts swapping, notably bars, stem, seatpost and saddle. That could add a couple hundred dollars to the price of a new bike. And generally speaking, the stock bars, stems... aren't worth a lot on the secondary market, so you wont' be able to recoup much of that.