To understand how each class votes, you have to understand what each class views as the principal barrier to their prosperity.
For the poor, the principal barrier to greater prosperity is the cost of living. They have dead-end jobs and the thing they worry about most on a daily basis is the cost of rent, food, utilities, etc. The path to greater prosperity in their minds starts with reducing their cost of living.
For the middle-class, the principle barrier to greater prosperity is inadequate income. They have jobs with theoretical upward mobility, but they're either not moving upward or they're not moving upward quickly enough. Unlike the poor, they are not struggling to pay for basic necessities, but they are struggling to invest money and build a nest egg for their futures. Therefore, the path to greater prosperity in their minds starts with job opportunities.
For the wealthy, the principle barrier to their prosperity is taxation. They don't need jobs, and many of them don't have jobs. Some of them play at pretending to work, but they derive the bulk of their income from capital-gains, shareholder dividends, and interest. They are in the highest tax bracket, so the path to greater prosperity in their minds starts and ends with tax cuts. More importantly, every rich person who inherited money had to pay a huge tax bill on that inheritance, so they carry around an endless grudge against taxes because they'll never forget that one big chunk of money they had to give away.
This is how you win elections: you tell the poor people that you'll cut their cost of living. You tell the middle-class people that you'll "create job opportunities" by getting rid of the competition (ie- immigrants, and/or women and minorities if you're an anti-DEI white guy) and cutting corporate taxes so employers can afford to hire more people (which is not how corporate taxes work at all, but I digress). And most importantly of all, you tell rich people that you'll cut their taxes.
Trump may be an idiot, but he understood enough to make exactly those three promises in his 2024 election campaign.