Your first command listing the formats is “useless”, depending on what you define the best quality is. yt-dlp orders the output by it’s format selection (-f argument) which is bestvideo*+bestaudio/best by default which also gets affected by the format sorting (-S / --formart-sort). By default av1 use is discouraged over vp9 so I’d highly recommend you look into them if you really want to make sure it’ll downlad the best quality ones. In my experience the default settings are really good, except some fringe cases (for example if you’d rather download av1 encoded videos). Keep in mind though most digital stuff still runs h264/h265 for compatibility reasons
Have fun learning and don’t forget to look over the yt-dlp ReadMe on github! It has all the information you’ll ever need and much more :)
Funnily enough that’s how I did it at first too. It’s good that you’re willing to put this much effort into understanding, confirming and improving things. Keep doing it like this and you’ll surely keep improving as long and as much as you want to :)