There is no reason to replace a bike every few years unless, A: you're wealthy and the cost to replace is meaningless; B: you have outgrown your bike's abilities and need something a bit better, but then once that's accomplished again there is no need to replace that one for a long time; C: you don't know how to ride a bike and you crash it all the time; D: you buy carbon fiber bike and ride a lot, so it's almost mandatory that you buy another every 5 years or so.
A good quality bike made of good materials will last easily 30 years, and believe it or not parts will be available.