

There were special long lived BlueRay format https://en.wikipedia.org/wiki/M-DISC . I was thinking of getting into, but they were expensive when I looked at it years ago. With 100 GB per disc, this might be a good solution for longtime archive (but you need the reader too…).
As for the CDs and DVDs, the longevity also highly depends on the burner, the blank disc and maybe the software and settings you used at that time. A pressed CD that you buy and its not burned can hold data for very long time, and is much more durable than your burned ones. At least compared to a mechanical hard drive you don’t need to reuse (rewrite) to not loose data. But a hard drive can hold so much data.
Consider buying used parts. And you don’t need the newest hardware. There is plenty of good last gen hardware, that is also much cheaper.