Most of what youtube needs is the non-time-critical filler of Google's workload so it's pretty flexible and cheap to host in whatever space is free in Google's data centers, which are already the most efficient ones. And with such a large amount of compute needed they can justify hiring a lot of people to optimize every little part of software and hardware involved with Youtube.
Google's infrastructure scale is such a big advantage for Youtube compared to competitors