Depends, is probably the most accurate answer.
If you feel the first house is undervalued, or you can add value to it, or that the area is likely to increase in value over the period you live there, then it could well be worth buying now then moving up. However you'd have the risk of that increase in value not being realised, as well as the risk of the place not selling quick at all when you want it to. Plus as you said there will be a bunch of costs involved when buying which that value increase will need to cover before it being beneficial.
Then again even if the house itself only breaks even, or a small loss, then would this likely be less than what you're paying for a place to live now? Or would having your own house/space be worth this additional cost over the time?
So as said, depends!