For experienced committed shooters, buy the best you can afford. When it becomes time to upgrade, sell your old gear and use it to help pay for the expensive new gear you want.
For new shooters, start small and upgrade as you need to. You will be surprised how little you need to rapidly move up the learning curve. Second hand equipment is just fine. Most new shooters are not sure they will fall in love with the sport, and want to do a try-out before they spend serious money. Best is usually to find a buddy who will allow you to shoot their rifle. After three weekends, you will know if you like it or not. Most guys will be hooked by then! Then spend what you can, even if you have to buy second hand equipment. Just start learning and try to get good at it.
Best advice i never took: Attend a professionally taught training class, it will save you a ton of money in terms of wasted ammo and frustration. I have recently managed to teach my niece to shoot 1/4” three shot groups in one afternoon, because she never acquire bad habits. I did, and it took a long time to remediate. That was a mistake. The shooter is by far the weakest link initially.
A scope is often two times more expensive than your rifle, because it is a precision optical instrument. Also, you can these days buy a fairly cheap rifle that shoots remarkably well. I started off 6 years ago trying to spend as little as i could get away with.... Spent $450 on a Howa 1500 and it was a superb starter rifle. After much head scratching, i went for a $900 Vortex Viper PST 4-16 (prices have since come down some). Many other good options in this price range too. The combo worked well enough, and after 6 months or so i could shoot 0.5” (three shot) groups at 100.
Switched to 200 yard range and groups went up to 1-1.5”. Realized then i had to acquire wind reading skills. Shooter was again the weak link, and the scope was not limiting my results. After upgrading ammo (HSM ammo loaded with Berger bullets) and within just a few months some shots would go though the same hole at 200. That motivates the new shooter to keep going!
Then ‘graduated’ to 400 and eventually 600. At this point i bought a new $900 rifle with a heavy barrel in 6.5 mm Creedmoor, with a crisp light trigger. The ‘cheap’ Vortex scope was now the limitation, as i often could not see my hits on steel. Hard to adjust for wind if you cannot see the splash marks on the 600 yard target. Thought about buying a good spotting scope, but the good ones were way too expensive for my budget, so instead decided to buy a top quality rifle scope that would do both jobs (rifle scope plus spotting scope). Picked the Nightforce ATACR 5-25 and it was more than good enough for the intended 600 yard purpose. Would even be fine at 1000 and beyond. Also realized that my vertical dispersion was now a problem, so i had to start reloading. More expensive gear!
The Viper scope is now on my light weight Howa hunting rifle, which i never use past 350 yards. Hunting ethics.
If i had known 6 years ago i would end up here, then yes i would have bought top quality equipment from the start. But you don’t know that ahead of time. So: Focus on climbing learning curve, and progressively upgrading the weakest link in the system, and at least initially it will be YOU!
Hope this helps!