For a desktop, make sure you select your motherboard (most critical component) with care - i.e. make sure you get the latest chipset /CPU slot design release you can. With the MB as a base you can happily game for at least 5-6 years (or more).
Just how many years depends on you continuing to upgrade the most important gaming component - the GFX card. If you are happy gaming with lower eye candy then you can further extend the system's lifetime.
You will, of course, need a CPU that matches the input requirements of your GPU. You don't need the highest tier/most expensive CPU.
For any Laptop you're going to spend much, much more for any equivalent performance to the desktop. You will also never be able to match a high end desktop - especially one kitted out for >1080p gaming (ignoring the fact that >1080p Windows Laptop screens are very rare). Laptops offer very limited upgrade options - I don't know of any manufacturer that encourages or allows for any GPU upgrade options for an existing Laptop (it's not impossible for some e.g. some Clevo's though you are very limited).
Thus a Laptop's longevity is much shorter than a desktop, particularly for gaming. If you have lots (and lots) of money you'll find custom laptops with xfire/sli options featuring high end mobile GFX cards.