How to prevent slowing down of Windows over time?

It’s not something new to say that the computers get slower over time, start hanging, and ultimately crash. You would have heard many people quoting the age of the computer (or the most recent OS reinstall) whenever you ask them WHY IS THIS RUNNING SO SLOW?