Try to go in Safari Settings > Advanced > Enable "Show developer menu". In the developer menu enable "VP9 SW decoder" and "VP9 SW decoder on battery".
Apparently, some older Mac doesn't support 4k on Youtube, you can still try to play them with Google Chrome.