What is the mindset of middle class people that keep them middle class?

That’s not how it works now (used to work that way, but it’s been a while). Now there’s just an exclusion (I think the amouint is $250k for single people and twice that for married filing jointly). Gain under that amount isn’t taxable whether or not you re-invest, and gain over that amount is taxable even if you re-invest.